question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parcel 2 cache problem on file changes during the build (CSS Modules with Astroturf)

See original GitHub issue

🐛 bug report

When you are using Astroturf (a tool which moves CSS-in-JS declarations to separated CSS Modules files) Parcel 2 nightly cleans CSS Modules export on any file changes.

But it works fine on --no-cache.

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

package.json:

{
  "private": true,
  "scripts": {
    "start": "parcel serve index.html",
    "start:fixed": "parcel serve index.html --no-cache"
  },
  "dependencies": {
    "@babel/core": "^7.12.9",
    "astroturf": "^0.10.5",
    "parcel": "^2.0.0-nightly.462",
    "postcss": "^8.0.0",
    "postcss-modules": "^3.2.2"
  }
}

.babelrc:

{
  "plugins": [
    ["astroturf/plugin", {
      "extension": ".module.css"
    }]
  ]
}

.postcssrc:

{
  "plugins": {
    "postcss-modules": {}
  }
}

index.js:

import { css } from 'astroturf'

let styles = css`
  .button {
    background: blue;
  }
`

document.body.innerHTML = JSON.stringify(styles)

I way to reproduce an error:

  1. Clone repo with error
  2. yarn start
  3. Open localhost:1234 browser
  4. See something like {"button":"_button_c6258"} in the browser
  5. touch index.js to force Parcel rebuilding
  6. Reload the page in the browser

🤔 Expected Behavior

Continue to see {"button":"_button_c6258"} in the browser

😯 Current Behavior

The browser will show {}, which mean that CSS Modules stopped to work.

If I will open the JS bundle I will see that the CSS file is empty.

💁 Possible Solution

If you will run yarn start:fixed (with --no-cache) everything will work correctly.

Seems like there is an issue in the cache system, which I was not able to detect.

🔦 Context

CSS Modules without Astroturf is working. I understand that my Astroturf use case is rare (but I still think that Astroturf is the best CSS-in-JS solution).

But this bug can show some deep bug in the cache system, which could affect many other use cases.

💻 Code Sample

Repo

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.462
Node 12.20
npm/Yarn 1.22.10
Operating System Fedora 33

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aicommented, Oct 26, 2021

Cool! Closing it.

1reaction
aicommented, Nov 26, 2020

Technically, we can convince the Astroturf team to create a Parcel transformer with in-memory complications. But I saw a few code generators even for Webpack because there are bloody edge cases. Especially for GraphQL.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stephan Meijer
If you're using the `.pcss` extension for your postcss files. Parcel 2 will not change the file extension to `.css` during build.
Read more >
Parcel Build Error: Error: Key 216aea59fec25090 not found ...
I got this error, and I don't know how to fix it. Error: Key 216aea59fec25090 not found in cache Error: Key 216aea59fec25090 ...
Read more >
wxI - River Thames Conditions - Environment Agency - GOV.UK
Mestky, Fear files episode 27 2012, Gin tonic shop antwerpen, Pulp fiction jack rabbit slims song, Raouche rock, Coloured hair for dark skin,...
Read more >
Writing Good CSS — Syntax Podcast 284
Big Deno Changes ... Part 2 of Wes and Scott React to the State of JS ... Potluck - Frameworks vs Libraries ×...
Read more >
Untitled
History of former president of nigeria, O2v arena, Top artificial turf companies, Termal oteller turkiye, Nuggets ii zip, Berghaus asgard hybrid jacket, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found