-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Current Behavior
When you destructure 2x useContext in a single component like so:
const { openToast$ } = useContext(ToastApiContextId);
const { openModal$ } = useContext(ModalApiContextId);Then you get an error like so:
frame: '\n' +
'\x1B[33mThe symbol "context" has already been declared\x1B[39m\n' +
'17 | const s_1SNzPtcSEoc = ()=>{\n' +
'18 | const context = useContext(ToastApiContextId);\n' +
'19 | const context = useContext(ModalApiContextId);\n' +
' | ^\n' +
'20 | useTaskQrl(/*#__PURE__*/ inlinedQrl(s_4rRz0sN06LY, "s_4rRz0sN06LY", [\n' +
'21 | context\n',
Expected Behavior
It should compile/serve/build without a problem (like in a standard qwik project)
GitHub Repo
https://github.com/intellix/qwik-nx-context-2-bug
Steps to Reproduce
- npm install
- npx nx serve bug --skip-nx-cache (or build)
Nx Report
Node : 18.20.2
OS : darwin-arm64
npm : 6.14.16
nx : 18.3.4
@nx/js : 18.3.4
@nx/workspace : 18.3.4
@nx/devkit : 18.3.4
@nrwl/tao : 18.3.4
@nx/vite : 18.3.4
@nx/web : 18.3.4
typescript : 5.4.5
---------------------------------------
Community plugins:
qwik-nx : 2.2.1Failure Logs
No response
Additional Information
Taken me quite some time to replicate this in a large project, because it works without a problem in a new qwik project on it's own. After deleting 99% of my project and seeing it still happened, I realised that it only happens in a qwik-nx project.
I'm not sure what's different from a regular qwik project but if you copy components/routes then you'll see it works in one.
This workaround doesn't work because I guess it gets collapsed down?
export function useToasterApi() {
return useContext(ToasterApiContextId);
}But it works if you make the function more complex so it doesn't get collapsed