vue-waypoint icon indicating copy to clipboard operation
vue-waypoint copied to clipboard

did bundle size increase going to version 4?

Open jaunt opened this issue 2 years ago • 2 comments

Hello,

Looking at bundle phobia, the gzipped bundle size went from 1.1kB to 40.4kB betrween version 3 and 4. Does that seem right?

https://bundlephobia.com/package/vue-waypoint

jaunt avatar Jun 01 '22 16:06 jaunt

This repository contains a whole application in order to have a working test. This does not mean that you should use the whole repository (you can use just the component, which is (https://github.com/scaccogatto/vue-waypoint/blob/master/src/components/Waypoint/component.vue)

But if you can strip everything off, PRs are welcome!

scaccogatto avatar Jun 03 '22 10:06 scaccogatto

Definitely, something is happening 🤔

I gave it a try to build Waypoint using Vite, it's only 2.5KB
And file content is very small 🤔

❯ npm run build

> [email protected] build
> vue-tsc --noEmit && vite build

vite v3.0.0 building for production...
✓ 4 modules transformed.
dist/waypoint.js   2.54 KiB / gzip: 1.03 KiB
dist/waypoint.umd.cjs   2.15 KiB / gzip: 1.00 KiB

Waypoint with Vite

image

Unpkg that shows huge file sizes

image

iamandrewluca avatar Jul 13 '22 15:07 iamandrewluca

Can you make a PR with a vite-based build system?

scaccogatto avatar Aug 09 '22 17:08 scaccogatto

Sure. Later today will do!

iamandrewluca avatar Aug 09 '22 17:08 iamandrewluca

@scaccogatto ok so the build is fine, but it seems there is a problem with the actual code using the latest vue, the @change callback is called indefinitely 🤔 The same happens in current code if I update dependencies. This happens because of this:

onMounted(() => (mounted.value = true));
onBeforeUpdate(() => (mounted.value = false));
onUpdated(() => (mounted.value = true));
onBeforeUnmount(() => (mounted.value = false));

mounted value gets switched true/false, which triggers an update, and the update triggers methods again. This behavior starts from Vue 3.2

I suppose onBeforeUpdate and onUpdated should be deleted, and onBeforeUnmount replaced with onUnmounted

What was the last command used for building the library? It is possible that you included --inline-vue flag, that's why the bundle is so big 🤔

ps: I'm not using this library in any project, just want to help

iamandrewluca avatar Aug 09 '22 19:08 iamandrewluca

This hook is sensitive, I would like to investigate. If you open the PR with just the build change I can maybe try to fix the thing.

scaccogatto avatar Aug 11 '22 13:08 scaccogatto

@scaccogatto PR ready for review!

iamandrewluca avatar Aug 11 '22 23:08 iamandrewluca