plentico / plenti

Static Site Generator with Go backend and Svelte frontend
https://plenti.co
Apache License 2.0
1k stars 48 forks source link

How to create additional packages for Plenti? #216

Open Fankhauser-Dominik opened 2 years ago

Fankhauser-Dominik commented 2 years ago

I wanted to create a Masonry Gallery with Photoswipe Lightbox support: Svelte Photoswipe Gallery How can I convert this into a Plenti conform Package? I'm a little bit lost about how to get that working. I would appreciate it, if someone could help me. It would be cool if we could have some guidance on how to properly write a package, to be used with Plenti. Or if Plenti would include a bundler.

Thank you

jimafisk commented 2 years ago

Hi @Fankhauser-Dominik, this is a totally reasonable request, unfortunately Plenti is not great at working with other packages at the moment. At the core we try to take the unbundled approach like Snowpack, but it currently only works with ESM ready packages that are simple JS (it doesn't know how to go into npm and compile a svelte file there).

Long-term it would be nice if we made Plenti work better with other packages, most likely with the help of esbuild, which we could use natively (just not sure how the svelte compiling step would work).

Short-term, here are a couple of potential solutions:

  1. Could you include a dist folder in your package with precompiled components?
  2. You could manually copy over your lib folder into a Plenti project and use it directly

Those probably aren't ideal suggestions, but let me know if you want to explore either of them. Thanks!

Fankhauser-Dominik commented 2 years ago

Hi @jimafisk Thanks for your reply. I already tried your second solution, but unfortunately, it didn't work for me. I will try to compile my Components. I will let you know if it works.

jimafisk commented 2 years ago

Yeah I'm having trouble getting it working as well. A couple of problems are holding this back:

  1. Plenti doesn't have typescript support (https://github.com/plentico/plenti/issues/47)
  2. Plenti can't import CSS files, is your bundler normally handling this (https://github.com/sveltejs/svelte/issues/3499#issuecomment-527505870)?
  3. I'm getting another error: SyntaxError: Unexpected token '-'

Plenti doesn't always play nicely with the JS toolchain unfortunately, hopefully we can make this better over time. For now, if work can be done with existing tools outside of the Plenti build, that might be the best path forward. Thanks for flagging this and testing your module @Fankhauser-Dominik.