When using a key and spreading props on a component, Qwik will import react as a dependency into the production server. The build will fail if react is not install.
For example, this code will cause Qwik to import react into the production entry.mjs file:
Notice the build will fail as it tries to find react.
If you install react, it will succeed and the entry.cloud-run.mjs file will include import 'react';
Which component is affected?
Qwik Runtime
Describe the bug
This one was interesting to find!
When using a
key
and spreading props on a component, Qwik will import react as a dependency into the production server. The build will fail if react is not install.For example, this code will cause Qwik to import react into the production entry.mjs file:
Reproduction
https://github.com/DustinJSilk/qwik-issue-react-import
Steps to reproduce
Install and build:
pnpm i
pnpm build.server
Notice the build will fail as it tries to find react. If you install react, it will succeed and the
entry.cloud-run.mjs
file will includeimport 'react';
System Info
Additional Information
It seems to work if you remove either the
{...post}
or thekey={post.name}
The workaround is to simply not use a spread with a key. So its not an issue, although no idea why it would happen