qwikest / icons

Include popular icons easily in your Qwik projects with @qwikest/icons πŸš€

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error during SSG

swwind opened this issue Β· comments

commented

I get the following error while compiling my website to SSG.

Cannot resolve symbol IoAlarm_component_EpS7H4rcUkE in {
  '02wMImzEAbk': [ 's_02wMImzEAbk', 'q-75a4e60b.js' ],
  '3sccYCDd1Z0': [ 's_3sccYCDd1Z0', 'q-aa1f739e.js' ],
  '8gdLBszqbaM': [ 's_8gdLBszqbaM', 'q-d6418d64.js' ],
  AKetNByE5TM: [ 's_AKetNByE5TM', 'q-16ed91ee.js' ],
  TxCFOy819ag: [ 's_TxCFOy819ag', 'q-75a4e60b.js' ],
  VkLNXphUh5s: [ 's_VkLNXphUh5s', 'q-b1e8c4af.js' ],
  zrbrqoaqXSY: [ 's_zrbrqoaqXSY', 'q-b668ba7f.js' ],
  EpaZ5qQ4Lg4: [ 's_EpaZ5qQ4Lg4', 'q-d6418d64.js' ],
  PrXIxv2vNXY: [ 's_PrXIxv2vNXY', 'q-d6418d64.js' ],
  fX0bDjeJa0E: [ 's_fX0bDjeJa0E', 'q-75a4e60b.js' ],
  kzjavhDI3L0: [ 's_kzjavhDI3L0', 'q-d6418d64.js' ],
  sKCu0TvdkZI: [ 's_sKCu0TvdkZI', 'q-16ed91ee.js' ],
  yiXwCC0m3jY: [ 's_yiXwCC0m3jY', 'q-d6418d64.js' ]
}
QWIK ERROR Error: Code(31)
    at createError (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:70:17)
    at logError (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:64:54)
    at logErrorAndStop (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:74:17)
    at qError (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:137:12)
    at serializeQRL (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:515:15)
    at Object.serialize (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:6116:16)
    at serializeValue (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:6376:28)
    at file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:4242:23
    at Array.map (<anonymous>)
    at _pauseFromContexts (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:4225:32) IoAlarm_component_EpS7H4rcUkE

Error during SSG
Code(31)
  Pathname: /
  Plugin: qwik-ssg
      at createError (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:70:17)
      at logError (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:64:54)
      at logErrorAndStop (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:74:17)
      at qError (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:137:12)
      at serializeQRL (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:515:15)
      at Object.serialize (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:6116:16)
      at serializeValue (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:6376:28)
      at file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:4242:23
      at Array.map (<anonymous>)
      at _pauseFromContexts (file:///home/swwind/Repositories/qwik-app/node_modules/@builder.io/qwik/core.mjs:4225:32)
error during build:
undefined

Steps to reproduce

  1. yarn create qwik
  2. yarn add @qwikest/icons
  3. yarn qwik add static
  4. Modify following files
// routes/layout.tsx
import { component$, Slot } from "@builder.io/qwik";
import { Link } from "@builder.io/qwik-city";

export default component$(() => {
  return (
    <>
      <Link href="/" />
      <Slot />
    </>
  );
});
// routes/index.mdx
import { IoAlarm } from "@qwikest/icons/ionicons";

<IoAlarm class="w-4" />

Then run yarn build and get errors above.

Possible solutions

  1. Remove class prop in <IoAlarm class="w-4" /> fixes the problem.
  2. Move code from index.mdx to index.tsx also fixes the problem.
  3. Remove <Link href="/" /> from layout.tsx also fixes the problem.

However, when the three things came together, qwik SSG panicked.

commented

Hey, thanks for reporting. I'll try to reproduce the error. Which qwik version are you running?

commented

Hey, thanks for reporting. I'll try to reproduce the error. Which qwik version are you running?

I tried the latest qwik@0.22.0 + qwik-city@0.6.2 and the problem still persists.

On

  System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 100.42 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.asdf/installs/nodejs/lts/bin/node
    npm: 9.5.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 112.0.5615.137
    Safari: 16.3
  npmPackages:
    @builder.io/partytown: ^0.8.0 => 0.8.0
    @builder.io/qwik: 0.103.0 => 0.103.0
    @builder.io/qwik-city: 0.103.0 => 0.103.0
    undici: ^5.21.2 => 5.21.2
    vite: 4.3.1 => 4.3.1

The icon won't be generated on SSG, we will just get an empty element.

<!--qv q:key=wQnO:W4_9-->
<!--/qv-->

But it works fine on client side rendering.

The problem can be reproduced on 0.0.5, 0.0.4, 0.0.3, that's all versions I have tested.

commented

I'll bump versions, reproduce and try to fix this. Sorry for the long delay, I'm currently moving into a new flat and working on a business idea – so not much time left 😁

commented

Probably connected to: QwikDev/qwik#3471

QwikDev/qwik#3471 (comment)

I think it may be ok to have only one entry point given rollup would do tree shaking, and everyone using qwik will be using vite.

commented

Tree-shaking will work fine, but the TypeScript autocomplete performance will suffer.

Anyway, probably a good idea for the time until multiple entry points are possible.

Could be a problem with too many candidates for autocompletion.

One possible solution could be (if qwik won't support multi entrypoints) to divide different icon sets into different packages.

commented

Seems that suffixing the bundle files like *.qwik.mjs is enough :)
I'll release a working fix today, where the package works both on client side updates and on server side:

Screen.Recording.2023-04-26.at.08.58.28.mov
commented

Hey @zhuhaow & @swwind I just released version 0.0.6 with a fix for this. I'd really appreciate if you could give me a short feedback if all issues are resolved πŸ‘

Hope you have a nice day!

Hi @NiklasPor, 0.0.6 is still not working for me with vite --mode ssr

Let me know if you need a reproducible demo

commented

@zhuhaow repro demo or repo would be great, --mode ssr now works for me on 0.0.6 with Qwik & Qwik-City version 0.103.0.

https://github.com/zhuhaow/qwikest-icons-ssr-bug

I only adad @qwikest/icons and it won't work, it generates just a empty element.

I'm guessing you used useVisibleTask$() somewhere so the element got rendered on the client side?

commented

No there's actually no server or client specific code in the library. I'll investigate your demo, thanks

commented

Hey all, after a lot of adjustments, api changes and testing I've released @qwikest/icons@0.0.8 – I'd be happy if someone gives it a shot.

Some icon names now might be different, the variants have been suffixed (because props are no longer an option with lite components, as they'd always be included inside the bundle).

Hope you all have a great weekend πŸ‘‹

The problem is solved in the latest version!

Thanks! πŸŽ‰ πŸŽ‰

This still occurs with the express adapter.

Some seem to load fine, others are just comments
image

image

I use the Fastify adapter and get the same problem, in dev mode it work fine but after building and running Fastify the icons appear only after an interaction like change a Signal value or a Link action.

This is still happening on "@builder.io/qwik": "^1.2.6" and "@qwikest/icons": "^0.0.8"

This is also still happening on "@builder.io/qwik": "^1.2.9" and "@qwikest/icons": "^0.0.8" :/

Also I am seeing this on the latest version with the Cloudflare adapter, dev is fine, on build, nothing.