Show HN: Jetpack – Webpack made more convenient
github.com
github.com
To the critics, in front-end land there are some programmers who believe that building an SPA is always a mistake. I am of the opinion that there are some types of applications that live in the browser that benefit from the UX enhancements that scripting can provide. We all know some examples.
Everyone knows that front-end land is a crazy wild-west with a lot of moving and a lot of breaking along with a lot of hype, trends, wheel-reinventing and cavalier attitudes towards security. The criticisms are mostly fair.
However, if you're building an SPA, there is a combination of tools out there that can provide a very conceptually clean (from an architectural perspective), performant, reusable, and highly productive and fun development experience. Of course, this doesn't mean these tools make building an SPA the appropriate engineering decision, they are just tools, only the requirements can dictate whether or not an SPA should be built.
This project attempts to preconfigure via webpack, what is IMO, the best selection of tools available for working on an SPA today. For me, these tools include:
- react
- react SSR
- bundle code-splitting
- es6 (or ts/es6+flow)
- es6 modules
- hot code and css reloading
- module aliasing
- css modules
- postcss
- reusing business and validation logic modules on the front and back end
All of these tools solve very specific (former) problems that one encounters while working on an SPA. Anyway, nice work!The challenge of course is the diversity of the ecosystem. Different projects are trying to address it differently, e.g.
* CRA is opinionated and unconfigurable
* Neutrino/pwa-cli propose a higher level plugin approach (i.e. install a plugin, without needing to configure it, in webpack plugins take many lines of configuration to configure)
* Next/Gatsby use a plugin system as well but are also specialised tools which means a lot of decisions can be abstracted
* jetpack tries to be application/use case/framework agnostic and provide you with the most commonly used/useful foundation, you can optionally add extra (e.g. sass), but you don't have to recreate the foundation (i.e. es6, jsx, modern css, css modules, hot reloading, serving, producing html, etc)
It's also about the DX, jetpack lets you run a dev server with a single command, it lets you analyse the bundle with a sigle command, it builds an optimised, split chunk bundle with a single command.
Just pointing out some motivations behind the project, I'm a fan of webpack, been using it for many years.
• https://wordpress.org/plugins/jetpack/
Which are the canonical URLs for JetPack, by Automatic.
KidkArolis will have a hard time promoting his project.
---
My suggestion for KidkArolis is to rename his project to one fo these:
• “ConvePack” considering the slogan “Webpack made more convenient”
• “WrapPack” considering the description “Jetpack wraps webpack”
• “SimplePack” assuming his project is simpler than WebPack
Or spiderpack?
Netpack?
Silkpack?
I remember one of the main Goal of WebPack 5 was sane defaults. ( I cant find the post anymore ) So hopefully the WebPack team can learn a lot from JetPack.
But I was worried about opening a Pandora's box of indirection design patterns.
I mean, who are we to assume that you want to invoke all this indirection now? Better to wrap it all in an IndirectionCommand so you can invoke it whenever you want.
And there's no need to keep too many copies of identical IndirectionCommand instances around, so you'll also want an IndirectionCommandCache class, which will of course need an IndirectionCommandCacheStrategy because you don't want to just assume you know how and for how long people will want to cache those commands.
I wanted something that is a good fouondation for _any_ project. If it needs extending, sure. But there's not much to remove.
You could argue you don't need all those plugins, but.. I would like to use jsx, async/await, css autoprefixing, css imports, hot reloading, compile it all for older browsers, split chunks and generate html. Those seem to be expected features today (or maybe that's a wrong assumption I have)?
Requiring the users to install 20 or more dependencies (@babel/, @postcss/, webpack-*, etc.) and write dozens of lines of configuration every time just doesn't feel right (or maybe it is..).
And we know what the developers need, they need to bundle a web project in a way that's optimised for production, js and css compiled to run on N (configurable) most recent browsers (optionally). But that's not that trivial in webpack, if it was, perhaps we wouldn't have so many abstractions trying to improve upon status quo.
Perhaps that's just an inherently difficult problem. E.g. there are many many ways to handle CSS, people use variety of transpilations such as TypeScript or Flow, projects have different requirements.
Another data point is that Parcel this problem in a much more "everything works automatically" way and it's really resonating with people.
Ideally webpack would be a set of composable pieces and you could use a simpler API for common use cases and drop down to a more granular abstraction when needed, but unfortunately as with HighCharts/d3, going from “batteries included” to “build from scratch” can be pretty jarring.
AWS used to be easy, now it's hard, and you almost need an AWS 'devops' person for it.
There is 100% a use case for an AWS light: simpler security model, basic services etc. that was hopefully on the ramp/learning curve to 'real' aws.
Git. My god git. A random smattering of arbitrary commands from the daily nuances of Torvalds. It's barely a product, it's useful only because it's powerful, but Git should have a set of commands that encompass everything you normally need to do (and reversible i.e. 'safe'), no 'golden rules' needed. Git in 'full mode' is really an administrator level tool. The arbitrary complexity of Git is really expensive and costing everyone a lot of pain and money. As a 'product' Git could have a couple of different API layers, if it had a different history.
I don't know enough about Webpack to really be specific, but it's feasible there is a problem.
Also - the makers of Wepback should consider the fact that someone went out and did this, and there there is a 'need of some kind not being met' possibly, after all, that's why we do these things.
DO just added Kubernetes support. Despite being pretty darn technical I don’t even know what kubernetes is and never intend to know.
So no, Digital Ocean is not planning to stay simple.
I npm install everything locally, never globally, and use npm run script to easily execute (and chain) stuff.
Am I in the minority?
* nodemon
* npm-check
* ndb
* serve
* webtorrent-cli
* jetpack
E.g. you could do something like:
cd ~/Desktop/foo
npm i somepkg
echo console.log(require('somepkg')()) > index.js
jetpack
And now you're running some pkg in the browser, to try/test it out. That's what the use case for this feature really is. For real apps, I install it locally as well or else a breaking change in the future could cause issues.https://github.com/asdf-vm/asdf
Now, a few new languages do come with pretty decent "virtual env" thingy-s , but most stumble for a few years.
So far (past year) I've been pretty happy with asdf. Mostly use it for ruby and node - but also rust and golang, lisp, Java and ocaml (mostly as a "consumer" of various cli tools, and/or toy projects.
Then, when you `cd` into your project directory, your environment with all its dependencies appears.
However, there are some downsides to this magical future tech:
+ Nix is hard to learn.
+ Not compatible with the standard environment managers for each language.
No, you are not. The disconnect between actual developers that know better than to rely on global pollution and the silly READMEs and blog posts that prescribe it is an interesting phenomena. It's also gone on long enough that I feel a little shouting is in order.
Global installs are for modules that are outside your projects dev cycle. With that in mind, a module such as nodemon can be installed both globally and locally. It depends on the use case.
Thanks!
[1]:
https://github.com/NoRedInk/jetpack
Also called Jetpack...
I'd argue one of the reasons Next.js is so popular is because you can get started with no configuration. It has optional configuration, but all the webpack config, css, hot reloading, route splitting, etc. all serves as a solid foundation.
Of course being zero-config you loose some flexibility.
The reality is, at this point, Webpack has become a powerful tool with a big ecosystem around it. Configuration is not that complicated. It used to be an absolute mess, but these days, the documentation is really good and there are many sensible defaults. It's worth learning without these wrapper solutions.
- meant to be not React only
- less opinionated in that it doesn't include jest
- smaller in scope/code, so easier to understand what it does by reading the code (?)
- allows extending configuration
- focus on SPA use case with jetpack/serve or proxy features
I should probably give CRA a proper spin though, it's popular and V2 seems pretty good.
[1] https://github.com/KidkArolis/jetpack/blob/master/docs/08-co...