Live data from Hacker News

Parcel CSS: A new CSS parser, compiler, and minifier

parceljs.org

31–40 of 129 posts

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#31

I feel stupid asking this question, but isn't the browser that parses css? i understand minifying css, but what does parcel's css parsing refer to?

To do the job of minifying, this minifyer first reads the CSS file into an internal datastructure. That process is called parsing.

All the minifying operations are done on that internal datastructure.

Then it writes it out again into a textfile, ready for the browser to parse it again - hopefully the minifying step made it a bit easier for the browser to parse this minified CSS.

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#32

I was just looking at Parcel a week or so ago to replace the stagnated Snowpack project for our frontend. Should I just stop trying to avoid it and just use Webpack 5, or can I actually rely on Parcel in a way I couldn't Snowpack? I just want to bundle my React app, I'm not trying to do anything special...

Snowpack, ESBuild, ..., all promised us nice frontend compiles, yet I still turn to Webpack every time I actually want everything to work - you always hit roadblocks you can't solve in these other tools.

That'd be my recommendation to you, still, sadly.

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#33
post #32

I was just looking at Parcel a week or so ago to replace the stagnated Snowpack project for our frontend. Should I just stop trying to avoid it and just use Webpack 5, or can I actually rely on Parcel in a way I couldn't Snowpack? I just want to bundle my React app, I'm not trying to do anything special...

Snowpack, ESBuild, ..., all promised us nice frontend compiles, yet I still turn to Webpack every time I actually want everything to work - you always hit roadblocks you can't solve in these other tools. That'd be my recommendation to you, still, sadly.

Not my experience. Both esbuild and vite have been great for my usecases.

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#34
post #25

> Parcel CSS is based on the cssparser[0] Rust crate, a browser-grade CSS tokenizer created by Mozilla and used in Firefox. This provides a solid foundation, including tokenization and basic parsing. However, it does not interpret any CSS properties or at rules. That's where Parcel CSS comes in. It handles parsing each individual rule and property value, as well as minification, compilation, and printing back to CSS.…

[deleted]

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#35
post #15

Earlier quoted context omitted.

Because the hex for green (#00ff00) needs more letters than using the named color.

That's an... interesting optimization, and one that might make sense if you only care about byte size, but intuition (which might be wrong!) tells me that this will be more expensive (especially if it saves only one or two bytes). I'd bet that browsers can more quickly parse a string like '0x00ff00' into its internal color representation than it can parse the string 'green'. It's probably faster to check for a '0x' p…

I doubt that difference it takes to parse green vs a 0x00ff00 is at all significant. It only should happen once per page load.

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#36

I was just looking at Parcel a week or so ago to replace the stagnated Snowpack project for our frontend. Should I just stop trying to avoid it and just use Webpack 5, or can I actually rely on Parcel in a way I couldn't Snowpack? I just want to bundle my React app, I'm not trying to do anything special...

Parcel is becoming my go-to choice most of the time now. I’ve migrated some apps out of CRA, pure Webpack and Snowpack to it and I need to say it was incredible.

Some minor issues with HMR on one of those projects I still can’t figure out. Anyway having something that works, with JSX, with TS, really fast, in just 2/3 really simple steps is amazing! You don’t even need to turn your brain on.

My two cents.

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#37
post #25

> Parcel CSS is based on the cssparser[0] Rust crate, a browser-grade CSS tokenizer created by Mozilla and used in Firefox. This provides a solid foundation, including tokenization and basic parsing. However, it does not interpret any CSS properties or at rules. That's where Parcel CSS comes in. It handles parsing each individual rule and property value, as well as minification, compilation, and printing back to CSS.…

It's really nice to see browser components being able to be reused easily rather than a bunch of half-assed parsers.

Agreed. If cssparser blows chunks on your css then at least you know that will probably break some of your user agents too, rather than the game of “is my tool broken or am I?”

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#38
For some reason I trust minifier / compiler benchmarks way more than I trust DB benchmarks. I wonder why that is?

Maybe I expect DB workloads to be much more varied so benchmarks are less representative. Whereas with minifying you can run it against some large project and expect it'll reflect your real world experience

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#39
post #20

I was just looking at Parcel a week or so ago to replace the stagnated Snowpack project for our frontend. Should I just stop trying to avoid it and just use Webpack 5, or can I actually rely on Parcel in a way I couldn't Snowpack? I just want to bundle my React app, I'm not trying to do anything special...

Use Vite instead, it has very nice developer experience. Webpack is a "legacy" bundler, while it is supported, is shouldn't really be used in new projects if you really value your sanity.

Webpack is under active development though, nothing legacy about it as far as I'm aware. Are you referring to abandoned third-party plugins maybe?

Vite and all the other bundlers are really awesome, but Webpack's strenght - and I think this may also be the root of the issues you seem to be having with the tool - is that there's almost no magic and barely any handholding. Freedom and reliability at the cost of having to build your own configuration (it's just dumping plugin config objects in an array, really not difficult).

Re: Parcel CSS: A new CSS parser, compiler, and minifier

#40
post #20

I was just looking at Parcel a week or so ago to replace the stagnated Snowpack project for our frontend. Should I just stop trying to avoid it and just use Webpack 5, or can I actually rely on Parcel in a way I couldn't Snowpack? I just want to bundle my React app, I'm not trying to do anything special...

Use Vite instead, it has very nice developer experience. Webpack is a "legacy" bundler, while it is supported, is shouldn't really be used in new projects if you really value your sanity.

> Webpack is a "legacy" bundler

How did you end up with this assessment? I'm not a fan either, but it's still very popular, I doubt it will go away in the next 5 years.

Post reply on HN