Skip to content
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

CSS @import layers are ignored in some situations #8162

Closed
matt-tingen opened this issue May 28, 2022 · 1 comment · Fixed by #8492
Closed

CSS @import layers are ignored in some situations #8162

matt-tingen opened this issue May 28, 2022 · 1 comment · Fixed by #8492

Comments

@matt-tingen
Copy link

🐛 bug report

CSS @import layers are ignored in some situations. For example:

@import 'red.css' layer;

body {
  background: green;
}

🎛 Configuration (.babelrc, package.json, cli command)

{
  "name": "parcel-css-layer-import-repro",
  "version": "1.0.0",
  "scripts": {
    "start": "parcel src/index.html"
  },
  "browserslist": "last 1 Chrome version",
  "dependencies": {
    "parcel": "2.6.0"
  }
}

🤔 Expected Behavior

The body should display green with css like this:

@layer {
  body.body {
    background: red;
  }
}

body {
  background: green;
}

😯 Current Behavior

The body displays as red because the css is compiled without layers:

body.body {
  background: red;
}

body {
  background: green;
}

💁 Possible Solution

🔦 Context

In my actual project, the non-layer override is defined dynamically via css-in-js. An example of this can be found in the react branch of the repro repo. I mention this because I'm not sure if parcel(-css) is trying to use static analysis to avoid @layer for compat, but doing so seems invalid when all of the declared browsers support @layer.

💻 Code Sample

Repro repo

🌍 Your Environment

Software Version(s)
Parcel 2.6.0
Node 16.13.0
npm/Yarn yarn 1.22.17
Operating System macOS 12.4
@devongovett
Copy link
Member

Bundling @layer is complicated, due to nested layers. Parcel CSS supports it, but we'll need to migrate the current Parcel packager plugin to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants