by tthisk · 7y ago · 0 comments
I do wonder how modular css fits into the picture of es modules though.
But it's perfectly possible to write a modern PWA using modern js, modules, and a library like react (loaded from a cdn) without any build step at all. I've done it, and it's not all that hard as long as you don't mind only targeting the latest browsers (and writing out a bunch of file names manually).
I think the reason it is like that is because there were many problems with JS "back in the day", and so people felt they had to come up with solutions.
Just look at Svelte. It's a library about compiling JS to get back to the "just JS" days. I mean, it's more than that, but it's about reducing runtime complexity. So another way to think about it is that writing "old style simple JS" is so convoluted that the author felt the need to write a translation layer from modern frameworks to old style JS. Sort of a mindblower to me haha (though, I love and agree with Svelte, to be clear).
The great thing though is that you can still use plain old JS, right? Nothing has changed for you if you don't want it. So is there really a problem?
This "modern web" stuff is just people solving problems. Some of these problems are the fault of old JS/web. Some of them are problems of our own making. Remember how amazing modern UI frameworks were? It's because we had PTSD from horrible jQuery codebases. A problem of our own making.
So stick with what you like, and other people can use the more complex stuff. It's a win win, no?
But I still like:
https://www.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool...
And the accompanying example repo:
https://github.com/keithamus/npm-scripts-example
I'm not eniterly clear on what parcel/webpack does better/simpler - maybe windows support?
I certainly see how one might prefer yarn over npm for dependency management, though - so maybe npm isn't as nice a build tool anymore?
But you can, if you build the project and then serve the "build" directory.
If that's the step that's bothering you, you can just not use Webpack, that's completely possible for all major libraries I encountered.
ES modules could also bring sanity to dependency management within the ecosystem. It is interesting to see the approach Deno JS is taking here as well.
Is the JS world trending away from Webpack now? When did this happen?
Webpack's complexity seems born out of necessity since back in the day a lot of things were just not there.
Parcel has no baggage and it shows in it's very lean offering that works without you needing to troll through stackoverflow, old github issues and forum links.
I've never understood why webpack got so much attention either. Both rollup and webpack are much slower than browserify, so I just keep using browserify. And I can get tree shaking with browserify by using a plugin too!