Parcel 2 Beta 3 – improved build performance
v2.parceljs.org
v2.parceljs.org
And how long before this approach becomes the de facto industry standard?
Most of the devs would use build higher level build tool like vite, create-react-app or custom build pipeline. Thus only small number of devs, who are directly involved in build process, need to make the change.
Both in React and Elm, it's made the friction of starting a new app much more tolerable, considering now I don't need to bring all the baggage that `crate-react-app` and the likes carry. Thank you!
Unfortunately nowadays I work with create-react-app or Gatsby because parcel gives me huge bundles, or breaks with tree-shaking on.
Really excited about parcel 2 though, I tried the alpha and it didn't work for me but hopefully this does.
The SWC-based transpilation looks like another big improvement. For anyone else who had a similar configuration to us, with some Babel packages installed to support Jest for running tests regardless of what Parcel was doing with the main build process, this also looks interesting, though we haven’t tried it yet:
https://swc.rs/docs/usage-swc-jest/
Edit: We have now tried it, but sadly several tests broke due to parsing problems. The cause remains a mystery so far, because the offending lines are in our application code and not our test files, and that same code does appear to build OK via Parcel. So it appears that SWC itself, at least as Parcel is using it, can parse everything involved, but for some reason to be determined, installing @swc/* packages directly as devDependencies and configuring the Jest transform for the relevant source files to use @swc/jest is not a drop-in replacement for the Jest+Babel combination we were using before. If anyone else has had more luck getting this working, and similarly getting ESLint to work well without needing Babel packages after moving other tools to use SWC, details would be appreciated! Otherwise, it looks like we’ll still need Babel for now to run the testing and linting tools, even if Parcel is using SWC for its builds.
I think Parcel 1's biggest issue was being really ambitious, and then never reaching maturity, in that it had bugs that weren't fixed. It wasn't maintained. So it had its own file watcher, for example, I believe, which is great in theory, but not when it's buggy and unmaintained. My personal style would be if I'm going to write my own version of something, write it in a really high-quality way, and keep it simple, either in API or implementation. Maybe reuse the same module for Parcel 2 and improve it, keeping the same API, or if I'm going to rewrite it, use the rewritten module in Parcel 1, or something. I wouldn't just write my own library for X, and Y, and Z, and put it out there, get a lot of people using it, and then move on. I love writing my own versions of things and taking on fun and ambitious projects, but I'd rather nobody use the code I write in my spare time, for free, and don't want to maintain, than create a liability for people.
Another issue I ran into is Parcel insisted on running "npm install", which was a feature that you couldn't turn off even if it didn't suit your project structure. This violates a few principles of mine.
It's an attempt to be "magical" in order to reduce the amount of configuration. "Magic" is not a good thing. Think about what makes a magic trick a magic trick: obfuscation. It's magic because you don't know what's happening, but you get one moment of delight out of it. Overall it increases complexity; it's the opposite of making things simple. Rich Hickey talks about how "simplicity" properly means simplicity of behavior, not fewer words on the screen. Keep the tool simple and understandable, and the way you instruct it what to do simple and understandable. If you want something to work well out of the box, by all means, build popular things like TypeScript into the core; have sensible defaults and explain what they are. But configuring a piece of software is a dialogue where you learn what the capabilities of the program are. There's no place for "do what I mean" in good UX.
Also, build tools should not treat development as something that happens from a unix shell, and try to "automate" it by shelling out to this and that. That's error-prone and likely not to be very universal or focused. Imagine if Webpack's core shelled out to "git" or something (to make up a random example). It would be ridiculous.
The biggest way to improve on Webpack IMO would be to make something that is both easy to get started with and easier to understand and customize for professional developers. Keep in mind that Webpack has been mature now for a long time, and it has extensive docs and guides, and tons of plugins, and you can write your own plugins without too much fuss... any alternative that is buggy (until further notice, maybe years from now if ever) and poorly documented (until further notice, ditto), and not inherently simpler or easier to understand or troubleshoot, while also having less of an ecosystem of available plugins, etc. is just not a good substitute.
To be fair there are definitely times I’ve run into issues, [there’s still an active issue I encountered ~12 months back with including postcss :,( ], but I find such issues are usually faster to solve than looking up the web pack equivalent.
I expect the utility of usin parcel depends on the complexity of the project.
We use Parcel 2 with yarn 2 pnp builds - it never runs "npm install", nor does it ever create a node_modules directory.
Wondering how new parcel performs against esbuild?
If you're starting out, I'd suggest spending more of your time in a higher level of the stack (like writing application code, learning React/etc), rather than spending time deeper down in the plumbing, especially if you're using cutting-edge pieces in the build pipeline.
https://v2.parceljs.org/blog/beta3/#roadmap
So it was expected that they would be breaking stuff on their way. I would rather say "I'll keep an eye on Parcel until it becomes stable".
Addendum: I manage a very small open-source product (https://www.planimeter.org/grid-sdk/), and when you're creating something that competes with an established incumbent, all you can do is your best and focus on the most impactful features. Individuals like the one above saying things like, "I'll be avoiding parcel like the plague," is really disheartening, but try and focus on their concerns more than the actual words they use.
Frustrated people are a goldmine for feedback that many projects simply do not receive. Take it in stride, know that you have something others do not, and use it to your advantage. It can be hard to separate your feelings from the words used, but there are diamonds there.
If you can find one, you can find ten. If you can find ten, you can find a hundred. And so on.
It’s also extremely important to remember that the opposite of love is not hate, negativity, or criticism. It’s indifference. Harsh critics can become some of your best users/customers/advocates if you’re able to learn from them and win them over.
It's tough to separate my ego from my work.
Sure the out of date dependancies thing could be seen as a problem with post-css plugins that require a newer version, but the unfortunate fact is that in webdev land, everything seems to evolve at a breakneck pace, foregoing backwards compatability. And when some part doesn't match, the buildtool suddenly becomes unusable. (webpack is way less easy to setup, the flipside is you can for example choose your postcss version)
Rather than backport to some beta version.
(Not giving Parcel zero blame in how ready they present themselves).
You beat me to it here; it’s a shame. That was my experience, too.
Any plans to replace Terser with something in Rust?
I'd love to finally benefiting from tree shaking and faster build times but I can't get anything to work. I hope they'll improve for the stable version, because Parcel 1 promise was that it just magically worked, which it did! I'd hate for Parcel 2 to regress on this side.
https://reactjs.org/docs/create-a-new-react-app.html#recomme...
ONCE.
But happily revert back. I have a single build.sh script with the proper build steps (them are so simply that make or other thing is excessive).
So, if you already know how do thing step by step, just do that!
Being stuck in Visual Studio 2019 right now for other reasons, I've been using some of it's "Lib Man" client-side library installers to help reduce the amount of gulp required too. Basically all your vendor/polyfill "lib" can just be brought and managed with a couple of clicks.
If you want to specify your supported browsers and utilize transpiling (babel), maybe do some image minification (svgo), compile using the latest sass module features (dart sass), create separate script bundles for required/deferred JS with revision hashes (rev), dynamically generate test/demo HTML files and test them (backstopjs) ... I can't imagine there is a system out there that can handle even half of those things so easily. I always assumed I would need to tell the system what to do.
If you do decide to go looking around at Gulp again, for myself after reading a few articles on Gulp setups I googled for "github gulpfile.js" to see what others had done as well and that helped.
Babel compilation is, by far, the slowest part of our full-stack build. That includes turning java source into jvm bytecode.
As they point out, there's a JIT warmup time. Testing against small projects that don't allow this makes JS transpilers look much worse than they actually are in real-world projects.
https://github.com/alangpierce/sucrase
https://github.com/alangpierce/sucrase/blob/main/benchmark/b...
It’s for good reason that the docs end on this note:
> You should think carefully before using Sucrase in production. Sucrase is mostly beneficial in development, and in many cases, Babel or tsc will be more suitable for production builds.
Amazing job
Parcel – Fast, zero-configuration web application bundler - https://news.ycombinator.com/item?id=21961963 - Jan 2020 (201 comments)
Parcel: Fast, zero configuration web application bundler - https://news.ycombinator.com/item?id=17547433 - July 2018 (91 comments)
Parcel – A fast, zero configuration web application bundler - https://news.ycombinator.com/item?id=15853149 - Dec 2017 (163 comments)
However, I have concerns about using Rust here. Not because it's Rust specifically, but because it means yet another native dependency. I've done my best to eliminate any native code from projects because they would always cause problems sooner or later. Mostly later when coming back to an old project. Are there any plans to optionally ship the compiler as WASM to avoid this?
When I come back to the project after some time, the first thing I need to do is update dependencies. I often had colleagues on whose devices some dependency would just refuse to compile for one reason or another.
Sure, this isn't the greatest problem in the Node ecosystem right now, but it's painful enough that I would rather not deal with it.