modular-forms icon indicating copy to clipboard operation
modular-forms copied to clipboard

Clearly indicate that ‘Qwik City’ is needed to use the ‘Qwik’ version.

Open iivvaannxx opened this issue 1 year ago • 4 comments

Context

This is not a bug issue or anything, it’s just a recommendation to clearly point out that you need Qwik City if you want to use this library with Qwik. I do not know if there’s any other framework like Qwik City to, as of today, work in a Qwik project, but I did recently run into this new integration for Astro which I started testing on a project of my own.

The thing is that, as my project has to deal with forms, I thought I could integrate this library also into the project to handle them. But just when I got everything to work, I received an error saying that a module from qwik-city couldn’t be found. That’s logical because my project does not use it, it uses Astro with the new Qwik integration.

Why?

My point is that, even though I may be blind, this should be clarified in the docs, to any developer that runs into a similar issue if trying to use the library with only ‘Qwik’ and not ‘Qwik City’. I also assumed it would work because with the other versions like React or Preact, you don’t have any framework dependency, just the library. Lucky for me, it’s not a big deal, so if you don’t find it necessary you can close the issue right away, I only have a simple form, so I can handle manually validating it by myself using Valibot (which, by the way, is awesome! you are a beast @fabian-hiller).

It’s mostly my fault because I could have noticed myself that I needed it by looking into the source code or something, but as I wanted to do a quick test I didn’t. There are examples in the docs where you can see that qwik-city is being used, but I thought that, as I only needed the useForm hook (which doesn’t require anything from that module or, at least, not externally), I could skip it without running into problems.

How?

I think that, even with only renaming the framework dropdown option from ‘Qwik’ to ‘Qwik City’, it would be clear enough.

iivvaannxx avatar Nov 16 '23 15:11 iivvaannxx

Hey 👋 you're right. I was already planning to release Qwik and Qwik City as a individual package in January. I think that Qwik City is currently only needed for formAction$. This means it should be possible to install @builder.io/qwik-city to remove the error message and still use Modular Forms with Astro without Qwik City.

fabian-hiller avatar Nov 16 '23 16:11 fabian-hiller

Good to see you think the same! I just tried installing the @builder.io/qwik-city, but :( sadly I receive a different error:

Cannot find module '@qwik-city-sw-register' imported from '/home/iivvaannxx/.../node_modules/@builder.io/qwik-city/index.qwik.mjs

I am guessing something is set up different when you run create qwik@latest that is not done by manually doing an install @builder.io/qwik-city.

iivvaannxx avatar Nov 16 '23 17:11 iivvaannxx

Too bad that doesn't work. The last solution would be to clone the repository and remove Qwik City and then use pnpm build && pnpm pack to create a custom package without it. Feel free to reach out if you want to try that and need help at some point.

fabian-hiller avatar Nov 16 '23 18:11 fabian-hiller

Yaaaay! I got it working that way! 🎉 Thanks @fabian-hiller!

I cloned the repository, removed the actions folder and the export from the index.ts file. Then removed any trace of qwik-city I saw and adapted the types so Typescript wouldn't complain while building.

iivvaannxx avatar Nov 16 '23 19:11 iivvaannxx