-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
parcel 2.4.0 breaks some CSS queries #7854
Comments
What is this syntax: |
These are both a little weird CSS "hacks" for IE detection and rules. The first one is actually part of the datepicker library I used (flatpickr). The second CSS rule is also an IE detection rule and was used by myself to show a broweser upgrade warning for unsupported browsers. |
Seems like what the @supports rule is for. I'm not sure we should support invalid CSS hacks like this. |
As mentioned it's part of an external library used (flatpickr) that uses that for styling. I'll see about replacing or overriding that then. Thanks for the feedback! |
I have the same error. It is reproducible when adding the following:
It gives the following error:
|
Also ran into this issue with 3rd party css using |
Sorry, but that's not valid CSS syntax. All modern browsers will completely ignore that rule. I don't think Parcel should be expected to implement Internet Explorer's bugs. The I think the code linked in that issue could be rewritten just using @supports. background-image: url("data:image/png;...");
@supports (background-image: url("data:image/svg+xml;utf8,<svg></svg>")) {
background-image: url("data:image/svg+xml;utf8...");
} |
Maybe we can see about sending some PRs to these libraries to replace these old hacks... |
I agree it would be better to not use this old hack any more but it’s a bit harsh that the css-transformer refuses to build any CSS that uses it. I’m not asking to implement IE bugs, I would just expect the css-transformer to do what any modern browser does: ignore it. |
I think most of the time it is much more useful for a build tool to show syntax errors than to ignore them. Otherwise you might miss one and accidentally ship broken code, or have to spend a long time debugging to figure out why your css isn't being applied as you expect. |
For finding syntax errors I’ll use a linter, e.g. stylelint or prettier. Usually, I only want to know about syntax errors in my own code though, not some other node packages. |
I'm running into the same problem due to a dependency's use of a different old-IE hack:
While I would prefer to have https://github.com/DataTables/Dist-DataTables-DataTables stop using it, I don't have control over their code so for now I'm working around by not updating Parcel. I would very much prefer for Parcel's bundler to either ignore this like all modern browsers do, or warn without refusing to build. |
Maybe you could use https://github.com/s10wen/stylehacks to remove these. It's a postcss plugin, so you just need a {
"plugins": {
"stylehacks": {}
}
} I tested it with the above code and it seems to work. |
This looks like it should work, but I'm missing something about how to use it. I installed stylehacks as per the instructions there, made a I've also tried adding:
to |
That should be working. You don't need a parcelrc, the postcss transformer is part of the default config:
|
Empirically, it either isn't working, or the addition of stylehacks doesn't achieve the intended goal. I did try quite a few permutations of the config, including not touching |
Is it possible that "transformers": {
"*.css": ["@parcel/transformer-postcss"]
} in |
PostCSS config doesn't apply to code in node_modules. Maybe that's the issue for you? |
Ah! That sounds likely, because this is specifically an issue caused by a Node dependency, which is why I can't just fix the CSS in my own project. |
Unfortunately, this is continuing to make it impossible for me to keep my project up to date with Parcel's releases. Which is a shame because you're doing really great work with the bundler in general. But I'm stuck with a dependency that I don't have the power to make compliant. |
You always have the power to take ownership of your dependencies. For example, you could fork it or use something like patch-package. Or you could build a custom Parcel plugin to do it like the one someone posted here: parcel-bundler/lightningcss#39 (comment). I'm open to an opt-in mode where things are less strict, but it's not as simple as just not erroring, we'd need to implement error recovery. My free time is limited though and it's not my top priority. Luckily, there are lots of ways to work around things like this. |
Thank you for these suggestions. Forking this particular dependency would add a great deal of work because of the tooling that it in turn needs to build it, but the other two options look realistic. I will try one or both in the coming week or so and report back in case that ends up being helpful to anyone else having similar problems. |
Thanks again! patch-package is a good solution for my needs, was easy to set up, and also has nice support for turning ad-hoc packages into PRs for the source repository. |
In parcel-bundler/lightningcss@69cbcca I implemented a new |
@devongovett any ETA for the release? |
Parcel 2.7.0 supports the |
@devongovett Is there a doc for I did try to use in package.json but it does not seem to work.
|
@ vishaldodiya Try setting |
I'm using Yarn Workspaces and one of my dependencies has buggy CSS. I had to configure
|
🐛 bug report
After updating to parcel 2.4.0, @parcel/transformer-css errors for some more edge case css rules.
E.g.
@media screen and (min-width: 0\0) and (min-resolution: +72dpi) {
errors during build and
@media screen\0 {
is transformed in a way that it's ignored.
🤔 Expected Behavior
CSS tranform works as before and correctly allows specific @media rules.
😯 Current Behavior
Css transform throws an error in some cases, or ignores some other rules.
E.g.
@parcel/transformer-css: Unexpected token Colon
for
@media screen and (min-width: 0\0) and (min-resolution: +72dpi) {
💁 Possible Solution
Revert to previous Parcel version.
The text was updated successfully, but these errors were encountered: