vobyjs / voby

A high-performance framework with fine-grained observable-based reactivity for building rich applications.
https://voby.dev
MIT License
879 stars 22 forks source link

Add rollup config #37

Closed iacore closed 7 months ago

iacore commented 7 months ago

PoC. Purpose: make bundled voby available on npm.

I didn't know how the build pipeline of this package works so I didn't touch it. I could have also added an iife bundle, but voby doesn't support being set as window.voby (I think).

To bundle: npm compile && npm bundle

When running the above command, rollup outputs a warning: "circular dependency". Maybe this is concerning?

fabiospampinato commented 7 months ago

There's a circular dependency in Oby but I think it's an acceptable one.

I'm not sure I see the reason for shipping it in bundled form, generally I don't do that. Why do you want this?

iacore commented 7 months ago

I wanted to use voby on my own site. To do that, I needed to copy all the voby files, which is a lot of files.

I think bundled script get executed faster, since there is no need to wait for script to parse, then import, then wait for script to parse, then import, then...

fabiospampinato commented 7 months ago

There are benefits to bundling, but in general in scenarios like this the end user would just use Vite, so the end user would do the bundling on their end. Have you considered it? Like in general you are not going to find all your dependencies to ship already pre-bundled, normally.

iacore commented 7 months ago

The use case is exactly when the end user doesn't use a bundler, especially if their website has no other JS requirements. Most static site generators do not come with a JS bundler.

I would say the need for that is not much right now, since voby is still "Work in progress".

fabiospampinato commented 7 months ago

🤔 I don't know I think having a bundler is entirely within the end user's power, and they should probably use one. I think it's probably best to not merge this. It could be revised in the future if somehow this becomes a major use case in the future and people really want it.

tienpv222 commented 7 months ago

@iacore I haven't tried it yet but I think there are some CDN services for this, for ex https://esm.sh/voby?bundle-deps might give you a single file for easy copy-paste. Or if you're using a module script you can import directly from there.