QwikDev / qwik

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

[🐞] Error when PandaCSS integration is added to a Qwik library #5181

Closed kattsushi closed 10 months ago

kattsushi commented 1 year ago

Which component is affected?

Qwik Runtime

Describe the bug

i am doing a new library of Qwik components

im expected to add any integration such pandacss to an qwik library

Reproduction

https://stackblitz.com/edit/qwik-starter-6gvajo?file=postcss.config.cjs

Steps to reproduce

npm create qwik library test-library-adding-pandacss

npm install

npm run qwik add pandacss

change postcss.config.js to postcss.cjs

npm run dev

Getting error regarding to vite-plugin-macro


`> my-qwik-library-name@0.0.1 dev

vite --mode ssr

VITE v4.4.7 ready in 840 ms

➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h to show help

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Failed to load PostCSS config: Failed to load PostCSS config (searchPath: /home/andre/test/test-library-adding-pandacss): [Failed to load PostCSS config] Failed to load PostCSS config (searchPath: /home/andre/test/test-library-adding-pandacss): [ReferenceError] module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/andre/test/test-library-adding-pandacss/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/andre/test/test-library-adding-pandacss/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///home/andre/test/test-library-adding-pandacss/postcss.config.js:1:1
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
]

Node.js v18.16.1

this is handle change the exstention of postcss.configo.js to .cjs but another error appears

ξ‚Ί οŒ› ξ‚±  ~/t/test-library-adding-pandacss ξ‚° npm run dev ξ‚² βœ” ξ‚³ took 4s ο‰’ ξ‚Ό

> my-qwik-library-name@0.0.1 dev
> vite --mode ssr

  VITE v4.4.7  ready in 862 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

  ❗️ Expect significant performance loss in development.
  ❗️ Disabling the browser's cache results in waterfall requests.
7:45:56 AM [vite] Internal server error: unreachable
  Plugin: vite-plugin-macro
  File: /home/andre/test/test-library-adding-pandacss/src/entry.ssr.tsx
      at wasm://wasm/00407106:wasm-function[927]:0xd9e10
      at wasm://wasm/00407106:wasm-function[1080]:0xdcdeb
      at wasm://wasm/00407106:wasm-function[704]:0xcf52f
      at wasm://wasm/00407106:wasm-function[284]:0xb3146
      at wasm://wasm/00407106:wasm-function[257]:0xaa365
      at get_macro_locations (file:///home/andre/test/test-library-adding-pandacss/node_modules/@builder.io/vite-plugin-macro/dist/index.js:174:10)
      at TransformContext.transform (file:///home/andre/test/test-library-adding-pandacss/node_modules/@builder.io/vite-plugin-macro/dist/index.js:450:21)
      at Object.transform (file:///home/andre/test/test-library-adding-pandacss/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:44240:62)
      at loadAndTransform (file:///home/andre/test/test-library-adding-pandacss/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:54896:51)
      at async instantiateModule (file:///home/andre/test/test-library-adding-pandacss/node_modules/vite/dist/node/chunks/dep-3b8eb186.js:55821:10)

System Info

System:
    OS: Linux 5.10 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (4) x64 Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
    Memory: 3.17 GB / 5.72 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 18.16.1 - /mnt/wslg/runtime-dir/fnm_multishells/2851_1695043547434/bin/node
    Yarn: 1.22.19 - /mnt/wslg/runtime-dir/fnm_multishells/2851_1695043547434/bin/yarn
    npm: 9.5.1 - /mnt/wslg/runtime-dir/fnm_multishells/2851_1695043547434/bin/npm
    pnpm: 8.6.11 - ~/.local/share/pnpm/pnpm
  npmPackages:
    @builder.io/qwik: 1.2.11 => 1.2.11
    @builder.io/vite-plugin-macro: ~0.0.7 => 0.0.7
    undici: 5.22.1 => 5.22.1
    vite: 4.4.7 => 4.4.7

Additional Information

No response

mhevery commented 1 year ago

I see, so it works fine in app mode but fails in lib mode. πŸ€” Any chance you can try to debug this?

gioboa commented 1 year ago

I followed the steps and it's working fine for me ( library mode ). Can you share a reproduction repo pls?

shairez commented 1 year ago

@gioboa if it helps, this also happens in Qwik UI / kit-fluffy (check out the vite.config.ts)

I had to comment out the macro lines in the vite.config.ts because I didn't have time to debug it

gioboa commented 1 year ago

These lines here I guess https://github.com/qwikifiers/qwik-ui/blob/3239860e895b1dfa9c09887a72f3e69858621c0b/packages/kit-fluffy/vite.config.ts#L12 Thanks @shairez for sharing. πŸ‘

shairez commented 1 year ago

exactly @gioboa !

kattsushi commented 1 year ago

I followed the steps and it's working fine for me ( library mode ). Can you share a reproduction repo pls?

sure here is a link box with the reproduction in stackblitz if helps https://stackblitz.com/edit/qwik-starter-6gvajo?file=vite.config.ts image

kattsushi commented 1 year ago

exactly @gioboa !

i can confirm that, commenting that macroPlugin now it is working but i don know what are the implications to do that fix, in another hand in the app mode does't have any issue with that plugin image

gioboa commented 10 months ago

Hey @kattsushi, I verified that now it's working fine with the latest version of Qwik. So I'm closing this issue for now, feel free to re-open it if it's still an issue for you. Thanks.