Skip to content

Improve css-loader cache to avoid failing build with nextjs and webpack#275

Merged
Jan Nicklas (jantimon) merged 1 commit intomainfrom
feature/fix_module_cache
Feb 12, 2025
Merged

Improve css-loader cache to avoid failing build with nextjs and webpack#275
Jan Nicklas (jantimon) merged 1 commit intomainfrom
feature/fix_module_cache

Conversation

@devbrains-com
Copy link
Contributor

After migrating more and more styled-components usages to next-yak, we started to experience failed nextjs builds (next build). The build ended without any error message and with a success status code, which is quite strange. After some time analyzing the issue, we were able to relate the issue to the parsed files cache within the css-loader.

Initially, the cache stored the promise resolving and parsing a module and its dependencies. A parallel request resolving the same module would, therefore, await the same promise and not load the module again. This likely led to a deadlock, or it has just exceeded the maximum number of concurrent loader executions.

Removing the cache solved the issue but slowed the build down quite a bit. With this PR, we change the cache to only cache the final result with the compromise of having the same module resolved more than once if requested simultaneously. Our performance test showed the exact same build time but without any failing builds.

@jantimon Jan Nicklas (jantimon) merged commit 79bb695 into main Feb 12, 2025
6 of 7 checks passed
@jantimon Jan Nicklas (jantimon) deleted the feature/fix_module_cache branch February 12, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments