Skip to content

fix(tests): handle unknown .jsx extension for TanStack solid dependencies (@ennajari)#7806

Open
ennajari wants to merge 5 commits intomonkeytypegame:masterfrom
ennajari:fix/vitest-tanstack-jsx-extension
Open

fix(tests): handle unknown .jsx extension for TanStack solid dependencies (@ennajari)#7806
ennajari wants to merge 5 commits intomonkeytypegame:masterfrom
ennajari:fix/vitest-tanstack-jsx-extension

Conversation

@ennajari
Copy link
Copy Markdown

@ennajari ennajari commented Apr 10, 2026

Fixes #7801

@tanstack/solid-* packages ship .jsx source files that Node.js cannot load without a JSX transform.

Fix: Add ssr.noExternal: ["@solidjs/meta", /@tanstack\/solid-.*/] to all three test projects (unit, jsdom, jsx). This forces Vite to bundle and transform them through vite-plugin-solid.

Test plan

  • pnpm vitest run completes without "Unknown file extension" errors
  • Tests importing @tanstack/solid-* packages run correctly

…cies

@tanstack/solid-store and related packages ship .jsx source files.
Vitest cannot load these directly in Node.js without a JSX transform.

Add all @tanstack/solid-* packages to deps.optimizer.web.include so
Vite pre-bundles them through its transform pipeline (including
vite-plugin-solid), and to ssr.noExternal in the jsx project so they
are also bundled in the SSR-like Node.js module loading context.

Fixes monkeytypegame#7801
@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Apr 10, 2026
@byseif21
Copy link
Copy Markdown
Contributor

hi @ennajari , did you test that really? cuz that doesn't seem like the full fix

Comment thread frontend/vitest.config.ts Outdated
Comment thread frontend/vitest.config.ts Outdated
@byseif21
Copy link
Copy Markdown
Contributor

btw @fehmer has assigned it to himself, so he may want to look at it himself, i think you should have asked before the PR

@fehmer
Copy link
Copy Markdown
Member

fehmer commented Apr 18, 2026

i don't mind somebody else fixing it, I haven't started working on it yet.

@byseif21 could you provide the test-case to reproduce the problem?

@github-actions
Copy link
Copy Markdown
Contributor

Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes.

@github-actions github-actions Bot added waiting for update Pull requests or issues that require changes/comments before continuing and removed waiting for update Pull requests or issues that require changes/comments before continuing labels Apr 18, 2026
@byseif21
Copy link
Copy Markdown
Contributor

@byseif21 could you provide the test-case to reproduce the problem?

sure, here

import { test, expect } from "vitest";
import { createHotkey } from "@tanstack/solid-hotkeys";

test("triggers jsx crash", () => {
  expect(createHotkey).toBeDefined();
});

try as a new test file (e.g repro.spec.ts in frontend/__tests__/), running it should fail in master

@fehmer
Copy link
Copy Markdown
Member

fehmer commented Apr 18, 2026

thanks @byseif21 ,

shouldn't the test be named repo.spec.tsx? Do we need to add the fix to all three kinds of test or only the jsxtest?

Just adding the regex to the jsxtests works for me:

  ssr: {
      noExternal: ["@solidjs/meta", /@tanstack\/solid-.*/],
    },

@byseif21
Copy link
Copy Markdown
Contributor

byseif21 commented Apr 18, 2026

shouldn't the test be named repo.spec.tsx? Do we need to add the fix to all three kinds of test or only the jsxtest?

hmm the thing is, wouldn't naming tests as .tsx be a bit inconsistent if they don't actually have UI components? I thought it was better to keep logic tests as .ts (like the ones in frontend/__tests__/) and only use .tsx for components?

tests like for the hotkeys one when we add it, it will be only logic test and if it'll be as ts as i think, importing e.g @tanstack/solid-hotkeys or anything that use it, makes it fail

@ennajari
Copy link
Copy Markdown
Author

Agreed with @byseif21. The repro imports from @tanstack/solid-hotkeys in a .spec.ts file, which matches the unit project (__tests__/**/*.spec.ts) — not the jsx one (.spec.tsx). Applying noExternal only to the jsx project would leave this failure path open.

Current PR already applies the regex to all three projects via a shared constant, so the repro should pass as-is. Happy to narrow it down if you prefer a different split.

@ennajari ennajari requested a review from fehmer April 23, 2026 08:24
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vitest crash: Unknown file extension ".jsx" for TanStack dependencies

4 participants