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.

Astroturf causes errors when using persistent caching with Webpack 5

See original GitHub issue

As discussed in #667.

Astroturf will cause errors when using Webpack 5’s persistent cache. It wouldn’t bother me too much if persistent caching simply didn’t work for Astroturf, but as it stands these errors block the use of persistent caching entirely and require the user to turn it off. I thought I’d file a separate issue for this since #667 seems to concern persistent cache support for Astroturf, whereas this is about a blocking error.

Here’s a minimal repro: https://github.com/lostfictions/repro-astroturf1-webpack5

To reproduce:

  • Clone the repo and yarn install
  • Run yarn start and open http://localhost:8080/ in your browser. Everything should work fine.
  • Webpack will have emitted persistent cache files to node_modules/.cache/webpack.
  • Close the watcher and open it again. You should get an error like this:
ERROR in ./src/index.js 2:0-52
Module not found: Error: Can't resolve './index-whatever.module.css' in 'repro-astroturf1-webpack5/src'
resolve './index-whatever.module.css' in 'repro-astroturf1-webpack5/src'
  using description file: repro-astroturf1-webpack5/package.json (relative path: ./src)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: repro-astroturf1-webpack5/package.json (relative path: ./src/index-whatever.module.css)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        repro-astroturf1-webpack5/src/index-whatever.module.css doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        repro-astroturf1-webpack5/src/index-whatever.module.css.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        repro-astroturf1-webpack5/src/index-whatever.module.css.json doesn't exist
      .wasm
        Field 'browser' doesn't contain a valid alias configuration
        repro-astroturf1-webpack5/src/index-whatever.module.css.wasm doesn't exist
      as directory
        repro-astroturf1-webpack5/src/index-whatever.module.css doesn't exist

webpack 5.24.2 compiled with 1 error in 191 ms
ℹ 「wdm」: Failed to compile.

Looks like it’s trying to find materialized versions of the virtual modules, presumably to check whether they’ve changed and the cache needs to be invalidated. I’d hazard a guess this could be fixed by telling the cache manifest to check the original source files (ie. index.js in this case) instead.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
jsg2021commented, Apr 26, 2021

@jquense so just add useAltLoader?

0reactions
jsg2021commented, Apr 26, 2021

nice!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Astroturf causes errors when using persistent caching ... - GitHub
Astroturf will cause errors when using Webpack 5's persistent cache. It wouldn't bother me too much if persistent caching simply didn't work ...
Read more >
Improving Webpack Performance via Caching
Using a combination of Webpack, Babel, and Lint caches, I was able to reduce my build times by up to 20x!
Read more >
New features in webpack 5 - LogRocket Blog
Webpack's recent update is loaded with new features: persistent cache, newly named chunk id, config changes, and more.
Read more >
Untitled
New models of health care, Andre santos mistakes, Grosvenor heights townhomes, ... Movie show timings in mantri mall, Ikon 5 architects, Joseph el...
Read more >
Writing Good CSS — Syntax Podcast 284
React use() hook and Async Server Components Proposal ... Sep 5th, 2022 ... Potluck - Multi Tenant Apps, JS Sprinkles, Kids Coding, Server...
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