Feature suggestion: support Snowpack

80 views
Skip to first unread message

Issac Trotts

unread,
Mar 13, 2021, 12:02:15 AM3/13/21
to phoenix-core
I've encountered some issues recently (example) where it would help a lot to be able to debug the JavaScript, but the output of Webpack makes that not work, at least with the default configuration. Luckily, there is an alternative that is advertised to not have this problem: Snowpack. Quoting from their site: "Snowpack serves your application unbundled during development." and "Single-file builds are easier to debug." 

I guess it would mainly be a matter of adding a "--snowpack" option to phx.new. 

If there is interest, I'd be happy to try my hand at adding this.

Issac

Nick West

unread,
Mar 13, 2021, 11:48:30 PM3/13/21
to phoeni...@googlegroups.com
Snowpack looks pretty cool, have you tried it out? What is your experience?

Repo says it has 342 contributors, however the oldest commit is only 7 months old, so I suggest caution re: adding it to the core as there is still time for the project to implode before it really matures. Might be better to add this as a third-party package first, like phoenix-snowpack or something like that.

Would be interesting to see how it works, though, and to see if it is/remains superior to Webpack.
--
You received this message because you are subscribed to the Google Groups "phoenix-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-core...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-core/a91f5075-3e06-4e8f-9f89-200d5e78332dn%40googlegroups.com.

Boris Kuznetsov

unread,
Mar 14, 2021, 5:41:41 AM3/14/21
to phoeni...@googlegroups.com
It would be really cool to have Snowpack as default frontend builder for Phoenix applications but it should be relatively easy to switch manually after project install.

I remember when Phoenix was using Brunch and there was a strong push towards Webpack.

Nick West

unread,
Mar 14, 2021, 6:02:17 AM3/14/21
to phoeni...@googlegroups.com
I disagree that it should be a default given that it is not nearly as stable as Webpack. With unstable JS packages, it only takes one compromised maintainer with a bad pull request for malicious code to get injected into every single project using the package.  

Would be interesting to have the option to use Snowpack in a Phx project, but as a 7 month old project with lots of hype, I don’t trust Snowpack to be my Phx build pack by default.

Issac Trotts

unread,
Mar 14, 2021, 2:33:07 PM3/14/21
to phoeni...@googlegroups.com
Nick, I've tried out Snowpack as far as working through their tutorial and found that to be a much nicer development experience than webpack since it only made minor changes to the JavaScript rather than mangling it beyond recognition.

Boris, it might be possible to use Snowpack as the default without loss of generality since Snowpack makes it easy to use webpack for production, according to their site. We could have roughly the same production builds and usable JavaScript debugging in dev.

Nick, couldn't we mitigate the risk of a bad Snowpack commit by pinning to a known-good version and upgrading occasionally after vetting?



You received this message because you are subscribed to a topic in the Google Groups "phoenix-core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phoenix-core/CkE2ryA6dvQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phoenix-core...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-core/CABdhv4OMGAB3avR-KEdy2L1q%3DStfH9aA%2BQTMEKvjquE4f3KhZw%40mail.gmail.com.

José Valim

unread,
Mar 14, 2021, 3:01:30 PM3/14/21
to phoeni...@googlegroups.com
Folks,

If we were to migrate to a JS framework every time a new one showed up on JavaScript, we would probably be on our fifth or sixth. Gulp/Brunch, Webpack, Parcel, etc... The issue with changing those is that it causes an incredible amount of churn. There are a bunch of articles on how to integrate Tailwind, Bootstrap, etc to Phoenix and they will all become invalid - and this information is valuable exactly for the folks who really don't care about Snowpack vs Webpack and just want to get that part of their stack done. For the folks who do care about this, then you can pass --no-webpack and bring your own.

Of course I don't rule out moving to Snowpack in the future but moving to it so early means an increased chance of churn. Churn now and potentially 1 year down the road if everyone moves to something else. The fact Snowpack is already on version 3,0 means it is still moving fast and that brings even more complexities.

So I don't see this change happening for now... if you like Snowpack, go for it and write how to do it! but definitely premature for a general migration.

Issac Trotts

unread,
Mar 14, 2021, 7:02:30 PM3/14/21
to phoeni...@googlegroups.com
It makes total sense not to migrate to every new JS framework that comes along.

What I'm mainly after here is a default where JavaScript debugging is usable so I can fix my own problems more of the time. If that is achievable with webpack, great. If Snowpack can do it, maybe it would be worth mitigating any risks that it brings.

So yeah, sounds like there's enough interest to make a demo of this. Agreed that general migration would be premature.

Issac




Issac Trotts

unread,
Mar 15, 2021, 10:01:55 PM3/15/21
to phoenix-core
Okay, I got Snowpack working with Phoenix and posted a tutorial within an example project. It turns out to be pretty easy to have Snowpack for development and webpack for production if you choose to do that.  

Issac Trotts

unread,
Mar 16, 2021, 11:44:16 PM3/16/21
to phoenix-core
I would like to appeal the closing of my pull request to add Snowpack support. That pull request keeps webpack in place for production, where it is undeniably useful and widely used, and uses Snowpack in dev so that JS debugging works.

Is there any variant of that pull request that could be accepted? For example, what if snowpack in dev was off by default and had to be enabled by a flag called something like --snowpack-dev?

Issac Trotts

unread,
Mar 17, 2021, 1:36:00 AM3/17/21
to phoenix-core
Or maybe not. Looking into this some more, I found out that it's possible in a project using webpack to just open up the webpack:// bit in the browser dev tools and debug readable code just fine.

So my main reason to use Snowpack just went away, so long as I can remember to open the webpack:// thing instead of the obvious thing.

Issac
Reply all
Reply to author
Forward
0 new messages