QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.65k stars 1.29k forks source link

[🐞] Qwik doesn't work with NX monorepo #6785

Open mhuretski opened 1 month ago

mhuretski commented 1 month ago

Which component is affected?

Qwik Runtime

Describe the bug

qwik 1.8.0 doesnt work with NX monorepo

Reproduction

https://github.com/mhuretski/qwik-monorepo

Steps to reproduce

  1. create project pnpm dlx create-nx-workspace@latest org-workspace --preset=qwik-nx
  2. update qwik to 1.8.0
  3. run project npx nx run PROJECT_NAME:serve where PROJECT_NAME - name of the created project (in attached repo npx nx run test:serve)
TypeError: Cannot read properties of undefined (reading 'push')
    at /Users/user/nx-test/node_modules/.pnpm/qwik-nx@2.3.0_@nx+devkit@19.5.7_nx@19.5.7_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+help_ptvdyo345eoikgktw5n5db5a2i/node_modules/qwik-nx/src/plugins/qwik-nx-vite.plugin.js:36:47
    at Generator.next (<anonymous>)
    at fulfilled (/Users/user/nx-test/node_modules/.pnpm/tslib@2.6.3/node_modules/tslib/tslib.js:166:62)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

System Info

"dependencies": {
    "qwik-nx": "2.3.0"
  },
  "devDependencies": {
    "@builder.io/qwik": "1.8.0",
    "@builder.io/qwik-city": "1.8.0",

Additional Information

If Qwik is downgraded to 1.7.3 everything works just fine.

thejackshelton commented 3 weeks ago

This has to do with qwik-nx. cc @shairez @dmitry-stepanenko.

Removing the qwikNxVite plugin "solves" the problem for the time being.

intellix commented 2 weeks ago

Code in question that's throwing here:

for (const qwikPlugin of qwikPlugins) {
    // it's not expected to have the plugin duplicated, but handling it as an edge case
    const pluginOptions = qwikPlugin.api.getOptions();
    console.log(pluginOptions);
    console.log(qwikPlugin);
    const vendorRoots = yield (0, get_vendor_roots_1.getVendorRoots)(options, pluginOptions);
    pluginOptions.vendorRoots.push(...vendorRoots);
}

pluginOptions doesn't have a vendorRoots array. I don't know if the solution is to default to an empty array or if none of this makes sense anymore?

pluginOptions.vendorRoots = (pluginOptions.vendorRoots ?? []).push(...vendorRoots);

I saw a load of pathing improvements added recently by wmorten relating to nx projects etc, is the qwikNx plugin still required? I feel like I have storybook issues without it but I'm not sure it's all related. My nx project is a little sensitive to package updates and sometimes wish I just used qwik CLI on it's own but think it doesn't support multiple apps/libs?

maiieul commented 1 week ago

From what we've seen, you can simply remove the qwikNxVite plugin from now on, qwik natively supports monorepos. @dmitry-stepanenko is working on a release.