Skip to content

Respect tsconfig jsxImportSource in JSX transformation#5

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-playwright-bug-repro
Draft

Respect tsconfig jsxImportSource in JSX transformation#5
Copilot wants to merge 4 commits intomainfrom
copilot/fix-playwright-bug-repro

Conversation

Copy link

Copilot AI commented Feb 15, 2026

Playwright's babel transform hardcodes its own jsx-runtime as the importSource for all JSX, ignoring the user's tsconfig.json. This means JSX in test files always produces {__pw_type: 'jsx', ...} descriptor objects instead of real React elements, breaking any code that passes JSX to React APIs like renderToStaticMarkup().

Error: Objects are not valid as a React child (found: object with keys {__pw_type, type, props, key})

Changes

  • tsconfig-loader.ts — Parse jsx and jsxImportSource from compilerOptions. When jsx is react-jsx/react-jsxdev with no explicit jsxImportSource, default to "react" (matching tsc behavior).
  • transform.ts — Add jsxImportSourceForFile() to look up the configured JSX import source from tsconfig, include it in the compilation cache hash, and thread it through to babelTransform.
  • babelBundle.ts — Extend BabelTransformFunction type with optional jsxImportSource.
  • babelBundleImpl.ts — Use user's jsxImportSource when present, fall back to Playwright's own JSX runtime otherwise:
    importSource: jsxImportSource ? jsxImportSource : path.dirname(require.resolve('playwright')),
  • loader.spec.ts — Two new tests: explicit jsxImportSource from tsconfig, and implicit defaulting via jsx: "react-jsx".
  • BUG_DIAGNOSIS.md — Root cause analysis.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 15, 2026 21:29
When a user's tsconfig.json specifies jsxImportSource or uses jsx: "react-jsx",
Playwright now honors that setting instead of always using its own JSX runtime.
This fixes the bug where React JSX in test files would produce Playwright's
internal {__pw_type: 'jsx', ...} objects instead of real React elements.

Co-authored-by: rwoll <[email protected]>
Copilot AI changed the title [WIP] Fix bug in Playwright as described in README Respect tsconfig jsxImportSource in JSX transformation Feb 15, 2026
Copilot AI requested a review from rwoll February 15, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants