playwright/packages
Max Schmitt 9fa06be49e
fix(ct): throw error if inline component is getting mounted (#32531)
What was happening?
- When we use CT, we go over the test files, look at the imports using
`tsxTransform.ts` and store them inside a map, these we feed into the
import registry which we build using Vite and have access inside the
browser
- In case of an inline component in the same file as where the test file
is, this is not happening.
- jsx-runtime via babel kicks in, transforms every JSX component in
something like that:

```
{
  __pw_type: 'jsx',
  type: [Function: MyInlineComponent],
  props: { value: 'Max' },
  key: undefined
}
```

this then gets passed into `wrapObject` which maps any function from the
Node.js side into expose function calls so they work inside the browser.
The assumption for `wrapObject` was to do it mostly for callbacks. So it
does for `type` - which is actually our component. We then pass this to
the React render function, which calls back the exposed function but we
never return anything, so it mounts `undefined`.

---

While there have been experiments from certain vendors to get the
'client only' code inside a server side file, we should throw for now to
not confuse users. We might revisit this in the future since Babel / TSX
doesn't support it outside of the box.

Fixes https://github.com/microsoft/playwright/issues/32167
2024-09-10 11:15:20 +02:00
..
html-reporter feat(html reporter): open html attachments in new tab (#32389) 2024-09-02 08:35:53 +02:00
playwright chore: revert the matcherResult in API (#32524) 2024-09-09 16:44:32 -07:00
playwright-browser-chromium chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-browser-firefox chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-browser-webkit chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-chromium chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-core feat(firefox-beta): roll to r1463 (#32529) 2024-09-10 08:57:40 +02:00
playwright-ct-core fix(ct): throw error if inline component is getting mounted (#32531) 2024-09-10 11:15:20 +02:00
playwright-ct-react chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-ct-react17 chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-ct-solid chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-ct-svelte chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-ct-vue chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-ct-vue2 chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-firefox chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-test chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
playwright-webkit chore: mark 1.48.0-next (#32466) 2024-09-05 12:57:16 +02:00
protocol/src chore: merge fetch params on server side (#32518) 2024-09-09 22:28:08 +02:00
recorder chore: allow recorder rewrite annotations (#32381) 2024-08-29 14:16:01 -07:00
trace/src feat(trace viewer): show baseURL in Metadata pane (#31852) 2024-07-25 17:14:46 +02:00
trace-viewer fix(ui-mode): use server side path separator (#32523) 2024-09-09 22:07:28 +02:00
web chore: roll expect and move it to third party (#32458) 2024-09-09 13:12:20 -07:00
.eslintrc.js chore: replace process.exit with graceful closure (#24242) 2023-07-24 08:29:29 -07:00