Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Qwik #19854

Open
zbynekwinkler opened this issue Jul 17, 2023 · 7 comments
Open

Support for Qwik #19854

zbynekwinkler opened this issue Jul 17, 2023 · 7 comments
Assignees

Comments

@zbynekwinkler
Copy link

Qwik uses vite so the basics should be there

However I am not having luck just trying to run vite as-is:

$ deno run --allow-read --allow-write --allow-env npm:create-qwik@latest
❌ Not implemented: net.Socket.prototype.constructor with fd option

If I use node to create default empty app and try running vite with deno I get a problem with sharp:

$ deno run -A --node-modules-dir npm:vite
error when starting dev server:
Error:
Something went wrong installing the "sharp" module

Cannot find module '../build/Release/sharp-linux-x64.node'
Require stack:
- /.../qwik-deno-plain/node_modules/.deno/sharp@0.32.3/node_modules/sharp/lib/sharp.js
- /.../qwik-deno-plain/node_modules/.deno/sharp@0.32.3/node_modules/sharp/lib/constructor.js
- /.../qwik-deno-plain/node_modules/.deno/sharp@0.32.3/node_modules/sharp/lib/index.js
- /.../qwik-deno-plain/node_modules/.deno/imagetools-core@4.0.3/node_modules/sharp/lib/index.js
...

That seems to be discussed here:

I have also tried using --node-modules-dir=true and populating the node_modules with pnpm and npm but that also didn't work.

It'd be great to be able to add qwik to create-vite-extra.

@zbynekwinkler
Copy link
Author

The dependency chain leading to sharp contains imagetools-core, vite-imagetools and finally qwik-city.

In the meantime, I tried just copying the files where they are being searched for but then I get:

$ deno run -A --node-modules-dir npm:vite --mode ssr
error when starting dev server:
Error: Platform not supported
    at loadPlatformBinding (file:///.../deno-qwik/node_modules/.deno/@builder.io+qwik@1.2.3/node_modules/@builder.io/qwik/optimizer.cjs:1329:11)
    at createOptimizer (file:///.../deno-qwik/node_modules/.deno/@builder.io+qwik@1.2.3/node_modules/@builder.io/qwik/optimizer.cjs:1355:93)
    at async Object.init2 [as init] (file:///.../deno-qwik/node_modules/.deno/@builder.io+qwik@1.2.3/node_modules/@builder.io/qwik/optimizer.cjs:1712:49)
    at async config (file:///.../deno-qwik/node_modules/.deno/@builder.io+qwik@1.2.3/node_modules/@builder.io/qwik/optimizer.cjs:3006:9)
    at async runConfigHook (file:///.../deno-qwik/node_modules/.deno/vite@4.4.4/node_modules/vite/dist/node/chunks/dep-abb4f102.js:66165:25)
    at async resolveConfig (file:///.../deno-qwik/node_modules/.deno/vite@4.4.4/node_modules/vite/dist/node/chunks/dep-abb4f102.js:65608:14)
    at async _createServer (file:///.../deno-qwik/node_modules/.deno/vite@4.4.4/node_modules/vite/dist/node/chunks/dep-abb4f102.js:64846:20)
    at async CAC.<anonymous> (file:///.../deno-qwik/node_modules/.deno/vite@4.4.4/node_modules/vite/dist/node/cli.js:743:24)

@zbynekwinkler
Copy link
Author

That most likely refers to qwik/src/optimizer/src/platform.ts#L134 where only node is checked for.

I was able to locally patch optimizer.cjs to return "node" instead of "deno" everywhere and I got a working qwik running with vite on top of deno!

$ deno run -A --node-modules-dir npm:vite --mode ssr

  VITE v4.4.4  ready in 869 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.
TypeError: error sending request for url (http://127.0.0.1:5174/@imagetools/30cc83c729e1f02924a4bd4b3577beb89ee24555): error trying to connect: tcp connect error: Connection refused (os error 111)
    at async mainFetch (ext:deno_fetch/26_fetch.js:266:12)
    at async fetch (ext:deno_fetch/26_fetch.js:490:7)
    at async getInfoForSrc (file:///home/zbynek/nanogrid-ws/deno-qwik/node_modules/.deno/@builder.io+qwik@1.2.3/node_modules/@builder.io/qwik/optimizer.cjs:2836:19)
    at async file:///home/zbynek/nanogrid-ws/deno-qwik/node_modules/.deno/@builder.io+qwik@1.2.3/node_modules/@builder.io/qwik/optimizer.cjs:2864:22
8:23:49 PM [vite] page reload src/components/starter/hero/hero.tsx

Even the hot module reload worked like a charm.

So it seems just two things are needed

  1. deal with the sharp package
  2. support deno runtime in qwik optimizer in addition to node

@zbynekwinkler
Copy link
Author

I've realized I should have started with why: Not being able to use Deno for development with Qwik precludes us from using Deno KV Store.

@pencilcheck
Copy link

How about this one? https://qwik.builder.io/docs/deployments/deno/

@zbynekwinkler
Copy link
Author

How about this one? https://qwik.builder.io/docs/deployments/deno/

Please see my comment above:

I've realized I should have started with why: Not being able to use Deno for development with Qwik precludes us from using Deno KV Store.

The deployment adapter allows only deployment, not local development and testing.

@birkskyum
Copy link
Contributor

@littledivy littledivy self-assigned this Feb 16, 2024
@ianlet
Copy link

ianlet commented Aug 8, 2024

I've realized I should have started with why: Not being able to use Deno for development with Qwik precludes us from using Deno KV Store.

@zwn I'm quite late to the party, but if your goal is only to use the KV store provided by Deno, you can now use this: https://deno.com/blog/kv-npm

That way you can use it in any server functions, even if you are outside the Deno environment.

That's what we are doing and it works well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants