ElMassimo/iles

Client:visible not downloading javascript of dependencies of a component as expected

TechAkayy opened this issue ยท 2 comments

Description ๐Ÿ“–

This is a followup of a discussion item (#267) I created earlier today where I wanted to download js/css from cdn during client:visible hydration of a component called BookAnAppointment.vue. Also had a discord chat on that topic here.

In order to avoid using a library via cdn, I replaced the datepicker solution with shadcn-vue, and added the date-picker to the above BookAnAppointment.vue component.

When testing it out, even though it has the client:visible directive, on checking network tab in devtools, the dependencies of the date picker (lucide-vue-next, etc) are downloading immediately on page load. So, basically client:visible is not working as expected, as it should hydrate the whole island as an individual app only when it comes into the viewport. Note the component itself if hydrating on visible as expected, but not it's dependencies.

Reproduction ๐Ÿž

https://github.com/TechAkayy/prozone-chairs-iles-shadcn-vue

Clone, install dependencies, run npm run dev to start dev-server, open devtools, check network tab. Search for lucide-vue-next which is used by the date-picker, and its already downloaded, while it should ideally download and hydrate the BookAnAppointment.vue only on client:visible.

Dependencies Info

Run npx iles info and pnpm list (or npm list) and provide the output:

`npx iles info`

iles v0.9.5 vite v4.4.7

`npm list`

pg-iles-tailwindcss@0.0.0 /Users/techakayy/Projects/pg/prozone-chairs-iles-shadcn-vue
โ”œโ”€โ”€ @11ty/is-land@4.0.0
โ”œโ”€โ”€ @iconify/json@2.2.96
โ”œโ”€โ”€ @islands/prism@0.8.0
โ”œโ”€โ”€ @nuxt/eslint-config@0.1.1
โ”œโ”€โ”€ @pinegrow/iles-module@3.0.34
โ”œโ”€โ”€ @pinegrow/tailwindcss-plugin@3.0.18
โ”œโ”€โ”€ @popperjs/core@2.11.8
โ”œโ”€โ”€ @preact/preset-vite@2.5.0
โ”œโ”€โ”€ @sveltejs/vite-plugin-svelte@2.4.3
โ”œโ”€โ”€ @tailwindcss/forms@0.5.4
โ”œโ”€โ”€ @tailwindcss/typography@0.5.9
โ”œโ”€โ”€ @types/node@20.5.0
โ”œโ”€โ”€ @unocss/preset-icons@0.57.2
โ”œโ”€โ”€ @vue/devtools@6.5.0
โ”œโ”€โ”€ @vueuse/core@10.7.2
โ”œโ”€โ”€ @vueuse/head@2.0.0
โ”œโ”€โ”€ autoprefixer@10.4.14
โ”œโ”€โ”€ class-variance-authority@0.7.0
โ”œโ”€โ”€ clsx@2.1.0
โ”œโ”€โ”€ daisyui@4.6.0
โ”œโ”€โ”€ defu@6.1.2
โ”œโ”€โ”€ eslint-config-prettier@8.9.0
โ”œโ”€โ”€ eslint@8.46.0
โ”œโ”€โ”€ iles@0.9.5
โ”œโ”€โ”€ lite-youtube-embed@0.2.0
โ”œโ”€โ”€ lucide-vue-next@0.314.0
โ”œโ”€โ”€ npm-run-all@4.1.5
โ”œโ”€โ”€ ofetch@1.3.3
โ”œโ”€โ”€ pikaday@1.8.2
โ”œโ”€โ”€ pinia@2.1.6
โ”œโ”€โ”€ postcss@8.4.31
โ”œโ”€โ”€ preact-render-to-string@6.2.0
โ”œโ”€โ”€ preact@10.16.0
โ”œโ”€โ”€ prettier@2.8.8
โ”œโ”€โ”€ radix-vue@1.3.2
โ”œโ”€โ”€ rehype-external-links@2.1.0
โ”œโ”€โ”€ solid-js@1.7.11
โ”œโ”€โ”€ svelte@4.2.0
โ”œโ”€โ”€ tailwind-merge@2.2.1
โ”œโ”€โ”€ tailwindcss-animate@1.0.7
โ”œโ”€โ”€ tailwindcss@3.3.3
โ”œโ”€โ”€ typescript@5.1.6
โ”œโ”€โ”€ unocss@0.57.2
โ”œโ”€โ”€ unplugin-auto-import@0.16.6
โ”œโ”€โ”€ v-calendar@3.1.2
โ”œโ”€โ”€ vee-validate@4.11.6
โ”œโ”€โ”€ vite-plugin-vue-devtools@0.0.22
โ””โ”€โ”€ vue-tsc@1.8.8

Logs ๐Ÿ“œ

If not providing a reproduction:

Output

Run DEBUG=iles:* npm run dev or DEBUG=iles:* npm run build and provide the output:


Screenshots ๐Ÿ“ท

image

The expectation for client:visible is that the component is created when the condition is met, not that it's script is downloaded only then (that would increase latency and time to responsiveness).

If you want to delay the load of a heavy dependency, try using dynamic imports instead, which can be paired with defineAsyncComponent if needed.

Gotcha, thanks for the clarification :-)