347 points · by gilad · 6y ago · 201 comments
I think it's always nice to call out the contributions certain corps are making to the OSS world.
Now, Parcel 2 has a core team of 9 active members from various companies including Adobe, Atlassian, and Eventbrite. We also receive funding on Open Collective which we distribute to a couple independent members of the team who aren’t already sponsored by a company. Definitely a multi-company effort at this point! :)
Parcel is good (and I use it), but it's likely if someone had pitched it internally I'd bet someone would have said "Webpack is good enough for us". At least that's how it would have gone at the places I've worked at.
It is blazing fast though and much less a pain to set up than webpack. Every time I have to touch webpack configurations I think: "Oh no, not that stuff again ..." and it will take time to get it exactly the way I want or even requires to load additional helper modules from NPM. Ugh.
For me sourcemaps is just working (I mainly use Parcel with TypeScript, so Parcel takes TS -> ES6+ -> JS -> Bundle). What's your path?
One constant problem with bundlers is how to rewrite the HTML files to match the JS/CSS bundles. You can do all kinds of crap including scripts with regexes, plugins, etc. but what if you could do better?
Put simply, Parcel does better. HTML files themselves can be entries, and they will be compiled such that all of the stylesheets and scripts are compiled, bundled and linked to the HTML file in the output. Now you don’t need to worry about mucking with writing the hash into your HTML.
Parcel isn’t perfect but it makes a great static site gen. Its plugin interface can be slightly cumbersome, but it’s flexible enough that you can abuse it pretty effectively. As an example, I used Parcel to generate some documentation built off of Kaitai Struct KSY files, which are effectively YAML files. I push the KSY data through an HTML template that generates the doc page. It was a lot of fun. You can see it here:
https://packets.pangdox.com/packets/loginservice/server/0002...
[ 'style-loader', { loader: 'css-loader', options: { modules: true } } ]
What could meaningfully be simplified in this configuration? We could get rid of the 'options' object, and spread into the parent object. But then that makes it more difficult for Webpack to statically know if the JSON tree provided is a valid configuration.
I don't see where this leads us. Instead of fragmenting the bundler market, invest in making Webpack better, or move onto to a new problem. There's a limited number of open source contributors out there, and only so much can be built & solved. The end state of a mature Parcel ends up looking basically like Webpack, which sounds like a fragmented, convoluted way of making a questionably impactful contribution to the OSS community.
To be sure, Webpack is pretty amazing for what it can do, but I consider it harmful for the stated reasons; I do not believe unification on Webpack is helpful because almost literally no two Webpack instances is the same because everyone is repeating basically the same configurations but slightly differently (or radically differently in the pathological end.)
Of course using Parcel doesn’t mean literally no configuration, usually it means standard configuration. All of these softwares work standalone and already do configuration. Need to configure the TypeScript compiler? Use tsconfig! Need multiple tsconfigs? No problem, put them in different folders and you’re good to go.
It’s unlikely you’ll end up with something compromise-free but like dropping to assembler and coding out routines manually the tradeoffs of getting your perfectly ideal output are not necessarily valuable to your fellow devs or your end users. It must be evaluated at some level. For me, Parcel does a good enough job that I trust it to have sane defaults for development and production.
So about your question with CSS modules: you can use .postcssrc as usual, although I do not use (or like, to be honest) CSS modules so I would definitely be the wrong person to comment on how well it is supported.
(Addendum: I anticipate that some will pick up on the duality of saying Webpack configuration is bad but condoning and recommending other configs. To that I would say, it’s all about the details. For one, most of these config files are auto discoverable, whereas for Webpack you gotta know the command invocation. For another, Webpack configs are often executable Javascript whereas most other configs are not used this way. And to be completely honest, the amount of magical configuration you can do in Webpack is hardly ever paralled elsewhere.)
You can also import stuff from wasm modules too of course, but I like the magic of "importing rust into JavaScript". It seems like a great way for someone like me, who wants to learn, to use rust into a simple web project without worrying too hard about wasm.
In Parcel you include the rs file. Seriously.
If you're building a modern web app, you're likely using more than just JS files. The compilation target is complex, and there's room for more optimizations when the bundler is aware of the app as a whole.
Parcel is here because most people don’t need to just bundle but also a whole pipeline for optimization and extended browser support (Babel)
Parcel by itself is small, but it could potentially require a lot less packages by default if it did that with other large dependencies: Babel, SVGO, CSS Nano, PurgeCSS/UnCSS, PostHTML, which are not required if you don't use Parcel to bundle JS/SVG/CSS/HTML.
To put it another way, would you willingly download and execute 730 programs from unknown authors on your computer?
If the host of the BaaS could be trusted, and they constantly vetted all packages, isn't that possibility less risky?
Now here is a very old and fascinating story - https://www.quora.com/What-is-a-coders-worst-nightmare/answe... and it's base, the seminal Ken Thompson Hack - https://wiki.c2.com/?TheKenThompsonHack
Sounds dangerous? It should. It is very easy to inject code in a small unknown dependency out of those thousands and effectively recreate the Ken Thompson hack.
I wish core JS had more functionality built in to alleviate the need for all these tiny packages.
Unfortunately it does not bundle to usable file for browsers, but SystemJS and AMD, and then we are back to RollUp or Parcel or Webpack.
One day...
It's the old tradeoff: Configuration (+ installation of multiple plugins, which may all break individually) vs. one system that already just works.
I guess Parcel 2 will be better in that regard.
Has anyone used Parcel and Webpack and still prefers Webpack?
https://github.com/parcel-bundler/parcel/issues/3690 https://github.com/parcel-bundler/parcel/issues/3691 https://github.com/parcel-bundler/parcel/issues/3696
So I switched to webpack. The configuration was miserable, but after I got it working, it seems to be OK. It's actually faster than Parcel, and a lot more stable.
https://github.com/magcius/noclip.website/blob/master/webpac...
Not to mention that I had a few issues with Parcel trying to be "too smart" for me. It would automatically try to hot reload, but my app wasn't designed for that, so it would break hard rather. The workaround was throwing an Error in the hot reload handler.
A sign of engineering maturity is knowing the right time frame to plan for relative to your project’s lifecycle. Don’t worry about how your solution will scale when your product is hugely successful and you have Google-scale concerns; focus on getting to next week or next year or whatever timeframe is appropriate for your product’s current level of maturity.
Sometimes that’s all you need
Parcel has some bugs that webpack doesn't since the latter has much better funding and corporate support from Facebook.
Still, I dig what the project is going for, and intend to try out Parcel 2 when it becomes stable.
Huh? Aren’t you confusing webpack with prepack?
I tried it in the past (maybe a year ago) and just 2 weeks ago, too. The experience I had was aweful. Pretty much nothing was working. Maybe I am too biased from Parcel and I got disappointed when even simple things such as starting with an HTML file as root module does not work, or when importing CSS does not work, or when using TypeScript does not work.
What I particularly disliked is that it cannot even cope with the standard stuff that I throw at it. CommonJS modules (only the standard...)? You need a plugin. Not only that: I had to specify what modules I wanted to include and what they export. Do you know a way around all these wholes or is your solution always pretty much self-contained?
Parcel and Rollup do the right thing 90% of the time (requiring only tweaking the path for the 10% remainder) with a single boolean configuration value.
Tried some other packager and ended with Parcel and Rollup. I like Rollup, i can not say why i prefer it over parcel. Both are better, easier, faster then webpack.
1. Become frustrated with complex build tool
2. Write a new tool that is dead simple, opinionated (your opinions), convention over configuration, etc
3. Post to HN
4. Achieve adoption
5. As more people use the tool, feature creep ensues
6. In order to satisfy diverse use cases, make everything modular and configurable!
7. Tool slows and becomes impossible to manage
8. GOTO 1.
We’ve been working on Parcel 2 for almost 2 years now (~1 year in design, another in development) and I think it strikes a pretty good balance. I’m excited to see what the community does with it! :)
Is it practical? Apparently it’s practical enough that it can compile Monaco Editor, which can either use a fairly hefty Webpack config, or no config at all with Parcel.
Where people stopp trying to make “pluggable systems” and “platforms” and instead tried to actually solve problems with finality, and to create procedural interfaces that cover a clear cone of responsibility, the result is mature libraries that stop changing, and become bedrock under applications.
I won’t say it’s “bad” not to strive for that. It is a unique challenge you may or may not wish to tackle.
After Web Bundlers are natively supported, bundlers can honestly focus on the build-pipeline problem area they naturally evolve into.
You know, when there's a sudden request for a new feature in a project that's been ticking along for five years - and you need to install a development environment to add said feature - but the build system has been abandoned for three years...
I think that is precisely what makes it so desirable in any project, no more organizational fighting about insubstantial stylistic matters.
I would love that ClangFormat was the same. If you leave the door open to interpretations, interpretations will enter the room.
He said “I’m the webpack developer”.
So, we make fun of a company that is serious enough about their web client to have a fulltime build engineer while we lament how little thought and care seems to be put into so many web clients in the wild. Maybe it turns out that clients aren’t always trivial and some specialization / division of labor is what it takes to make a good product.
It wasn’t long ago that you could see HNers snicker about fulltime “front-end developers”. I mean, isn’t it just HTML and CSS? How hard could it be? Isn’t the server API the only hard part of building a rich client??
In most projects, the webpack configs are not edited often, maybe unless you're upgrading a new major version of Webpack itself.
It is much simpler to manage so far (though upgrading internal dependencies in general could be an issue over time). It compiles much faster as well. I'm not sure how the default bundle size compares to what we had with Webpack though.
An ideal bundler would take a fully working unbundled project, which is easily writable with JS modules now, and just optimize it for production delivery.
The unbundled working app will be easier to develop and debug. Having a working project as input, and working project as output means that you can switch bundlers and aren't tightly coupled to it's transforms.
But most bundlers don't work this way (Rollup is the closest, and that's why I use it). Bundlers are typically entire build systems with compilers, CSS transforms, image optimization, etc... and they happen to bundle somewhere in the build pipeline. In the worst cases it's not possible to run the build but _not_ bundle, if you wanted to run some of the transforms.
This is all kinds of bad for the JS ecosystem. You can't really tell how a module will behave because the bundler is transforming everything. Imports aren't really imports, CSS is concatenated and magically added to the main document. Sometimes libraries publish code to npm that _only_ works with certain bundlers.
Web Bundles[1] is the way out of this. It's a standard bundle format that'll be natively understood by browsers, is unpacked before the network cache, and _only_ a bundling format. If you just want to bundle a working project, any Web Bundle tool will work.
It’s like saying a garage is the solution to your moving needs.
I don’t understand why they don’t support that. You can really leverage smaller bundles this way (no bundler runtime for modern browsers for one). You can also leverage type=module in the browser (which parsers more efficiently by default[0]) and use the nomodule attribute for differential loading.
Of course this assumes browser targets, which I feel like is the main target for these tools most of the time.
If you know you're targeting modern browsers, the need for bundling is slowly disappearing again. And if you're targeting something like electron, there is _really_ no need to bundle because you're distributing the entire filesystem with load times that don't involve network requests.
I can imagine at some point you might need more customizability with a tool like webpack - or maybe this will always be sufficient?
I believe the new version will make it fairly easy to do differential builds - so users with modern browsers don't have to download all the Polyfilla but it still works on IE
[1]: https://github.com/parcel-bundler/parcel/issues/1557#issueco...
Have an entrypoints for a react app? Include that in the build and parcel can bundle and deploy with no configuration. It just knows it's react because of the import react statement. Want to use typescript with react? Just use .ts files.
So my parcel command while developing is something like 'parcel watch src/*.ts. I just put my entrypoints there and my components below that. I've actually been able to just code for a while now without having to fuss with build tools.
Out of the box, with the default configuration, it already supports JSX, including hot-module reloading. So yes, it could be a replacement.
I've also written a small article comparing different options: https://blog.bitsrc.io/choosing-the-right-javascript-bundler...
I feel like node getting native es modules was the last step that the platforms needed to get up to speed with the bundlers. And the state of HTML, CSS, and JavaScript is good enough to simply use it without any external helpers (until production that is).
At the very least, it's nice to default to parcel on a project and then, if needed, adopt webpack once your project matures the point of needing more fiddling.
I think they fixed this in Parcel 2 but didn't try yet.
and another build tool that's perf optimized: https://github.com/swc-project/swc
(And swc is more similar to Babel than to Webpack/Parcel.)
https://github.com/packem/packem/issues/4
oh yikes, the fact that it's closed as "irrelevant" is rather worrisome. how is it irrelevant to ask where the source code is for a project hosted on an open source hosting platform.
one of their top talking points is "Its crust is built with Rust", but without source to verify this it might as well be written in brainfuck.
sorry for linking it :(
All I need now is some one shot solution for eslint + prettier. Right now that's 7 dependencies, representing almost all the dependencies I add to most of my mini projects.
im less interested in replicating the contract of CRA now, and want other defaults, so i made https://github.com/sw-yx/rincewind
Takes just as long to learn, and is transferrable everywhere.
Real answer: probably, but a ton of production code is closed-source.
But why restrict to web apps? Most influential software projects in the world use Make.
Not sure if it is up to the speed of Parcel though.
With that said, it's good that someone is challenging Webpack, as that must happen for the sanity of all.