-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error with star-prefixed css properties #39
Comments
Hmm not sure what to do about this. That's invalid CSS according to the spec. Browsers would ignore it, but we raise errors at build time instead so you can catch mistakes. Maybe we can have some kind of exception for this pattern, though not sure how much it's used in more modern code. |
In general i think it's OK and helpful to throw for out-of-spec input. But if browsers are able to ignore it a case could be made that other tools should be as well. The errors in the benchmark could be resolved on their end by better error handling or updating input data to remove outdated css. |
So I guess we have two options:
Both might be a little challenging without modifying the underlying cssparser crate, but I'll give it a shot. |
Something to take into account is that Microsoft will have dropped all IE support by June 15, 2022, with only IE 11 as of writing receiving any support. Allowing certain CSS errors to support CSS hacks in long since abandoned browsers may be unexpected behavior for most users. |
I think I have seen another case yesterday While I understand those are hacks for old browsers, they are none-the-less used in the wild and sometimes it's an import that people have no direct control over. I think it would ease adoption if those were preserved unchanged (or could be removed automatically if minification specifies that IE isn't supported) |
the benchmark has removed the files with invalid syntax and added @parcel/css https://goalsmashers.github.io/css-minification-benchmark/ The performance numbers are crushing across the board 🚀 The original trigger for this issue is resolved and i believe/hope that users don't run into this or rather appreciate the hint and fix their css. |
In regards to file size, one difference is that other benchmark is not setting any browser targets so Parcel CSS cannot remove vendor prefixes etc., whereas in the benchmark here it does. Another thing to keep in mind is that many of the other tools listed there perform unsafe transformations such as merging non-adjacent rules. So they may appear to produce smaller style sheets but may also change the behavior. Parcel CSS only does safe transforms. |
It should additionally be noted that CSS hacks were never necessary to target IE 6 and 7 anyways. IE conditional comments were standard practice for selectively applying styles to those browsers back when I worked on those kinds of projects, so I recommend that in lieu of introducing inconsistent error handling. I second closing this ticket until someone comes back with a real world use case. |
@evantbyrne yes IE conditional comments do exist, but I'm not sure a lot of libraries out there provide a "ie7.css" and an "ie11.css" file. It's definitely more interesting to have a single file where all the browser-specific adjustments can coexist. |
Projects still requiring these specific IE hacks are very unlikely to switch to parcel-css for their css minification needs. There is a possibility that there are other uses that could warrant a mode in parcel-css where invalid rules are tried to be kept, but that should be discussed when presented rather than investing resources and complicating the internal structure now. regarding file size discrepancy in benchmark: |
Having the need to support old browsers isn't necessarily correlated with the tooling you are using around. So that doesn't exactly apply to me, but if parcel/css came out last year I would definitely have wanted to use it for those builds that ship for IE 11, it's not because I have to support old browsers that I don't want fast tools. |
I don't agree with that. Should we disable all optimizations that other minifiers don't perform? Should we disable optimizations in other minifiers that Parcel CSS doesn't perform? |
@onigoetz Unfortunately there's a tradeoff and right now the reported issue is a hypothetical problem. Stopping on syntax errors is a valuable feature generally. To support IE 6/7 specific CSS parsing, then parcel-css would either need some kind of IE 6/7 mode or to regress syntax validation across the board. That's the reasoning for my recommendation. Best of luck working with IE 11, it wasn't that long ago I had to support that version as well so I know your pain! |
@evantbyrne In understand the tradeoff, and I understand that it would be complicated to add that support. I would then recommend to add a note in the documentation that IE hacks aren't supported as this might surprise people. As said, they might have that not only in their own code but in libraries that they might import and have no control over. |
It's not a hypothetical problem. I got here by googling "parcel ignore css syntax error" because a CSS lib I'm trying to import has an asterisk'd property. I just need to get this thing working with Parcel as if it were in the browser, and move on. |
In the meantime, is there a way to hook into Parcel's workflow so that I can just |
I was able to get around this by creating a custom transformer plugin that removes any asterisk prefixed css rules. I don't plan to support old browsers so this is okay for my usecase. const { Transformer } = require('@parcel/plugin');
module.exports = new Transformer({
async transform({ asset, config, logger }) {
const source = await asset.getCode();
const replaced = source.replaceAll(/^\s*\*.+$/mg, '');
asset.setCode(replaced)
return [asset];
},
}); This changes my error message, now I get
Not sure where to go from here but sharing in case this helps someone else :) |
As of the above commit, there is a new |
Hello everyone, In this scenario, ignoring or returning error on invalid css is not an option, i have to just preserve invalid rules and also support I have made a little change in Cargo.toml:
|
results in
found via css-minification-benchmark. GoalSmashers/css-minification-benchmark#101
Some of their test data is old and still has them: https://github.com/GoalSmashers/css-minification-benchmark/blob/e1d52eaea8e1107e95ea06f5cc085227cd36b2c0/data/gumby.css#L1216
iirc they were used to add special treatment for ancient IE
https://stackoverflow.com/questions/1667531/what-does-a-star-preceded-property-mean-in-css
The text was updated successfully, but these errors were encountered: