-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Is your feature request related to a problem?
After working with Qwik for almost a year and migrating an entire web design company from Next.js to Qwik, we are happy that we made this choice. Qwik is fast, and we add pages without worrying about the performance trade-offs and penalties.
Now, we want to give you some feedback on ways that you can improve your code.
We are very strict about boilerplate code. We do our best and go beyond our ways to reduce boilerplate as much as we can. These are some examples in our internal static-code analyzer:
- If there is an arrow function with only one parameter, we ask parentheses to be removed
- We don't use parentheses and empty fragments to enclose a JSX, we use one of them but not both of them together
- If there are multiple imports from the same
from
clause, we emphasize merging them together - We use barrelling extensible to reduce the paths inside the
from
clause - ...
The point is we eliminate boilerplate as much as we can.
However, Qwik is filled almost with boilerplate. These are examples that we see:
- The long name of the package. We need to write
@builder.io/
to access imports constantly. That's not the case withreact
ornext
. - The dollar sign is almost useless for us after a year of working with Qwik and after using it in more than 50 projects.
- The need to enclose a component with
component$
is useless for us. We wish we could eliminate it. - The
head
element, which should be a named export, is a pain now. We have hundreds of pages that need to repeat five lines of code. - We found ourselves using
strategy: 'document-ready'
on all of ouruseVisibleTask$
usages.
Describe the solution you'd like
1- We wish we could write qwik
and qwic-city
in our imports. For each import
we add @builder.io/
, which is 13 characters. Multiply it by two per component. Then, multiply it by thousands of components across many projects.
2- Why onClick$
and why not onClick
. I read $ and may we ask for a flag to turn all of my JS code into $ codes automatically? We accept that. We say it after thousands of components in many different real-world projects. We prefer Qwik to consider our code to be fully marked with $. But we're tired of writing it constantly. It meaks code less readable.
3- We wish we could have the option to tell Qwik that all of our components are the same, thus not asking us to enclose them all with component$
. We want to write all of the components in Qwik as simply as we can in Next.js.
Instead of:
import { component$ } from '@builder.io/qwik`
const Hero = component$(() => {})
We wish we could write it as:
const Hero = () => {}
And still, be able to use everything inside it. That means reducing 58 boilerplate characters per component. Multiply it by thousands of them, and you'll get a huge number.
4- This is what we have to copy/paste between all of our pages (hundreds of them):
const head = ({ resolveValue }) => {
return useSeo(getData, resolveValue)
}
export { head }
Not even one character changes. Why should we undergo this boilerplate?
5- Maybe we have used useVisibleTask$
more than a hundred times in our code, and all of them have this at the end:
, {
strategy: 'document-ready'
}
Can we get an option to make it the default strategy?
Describe alternatives you've considered
There is no alternative that we can think of. If we remove component$
code won't compile. If we remove head
from our index pages, we lose our SEO capabilities. If we remove $
code won't work. If we don't put strategy: 'document-ready'
code won't work.
Additional context
Please note that we are thankful for your fantastic library. These are just some feedbacks from real-world projects from a team that is sensitive to boilerplate.
Thank you so much.