Skip to content

Rspack persistent cache bug repro - #1

Closed
slorber wants to merge 2 commits into
mainfrom
slorber/repro-code
Closed

Rspack persistent cache bug repro#1
slorber wants to merge 2 commits into
mainfrom
slorber/repro-code

Conversation

@slorber

@slorber slorber commented Feb 20, 2025

Copy link
Copy Markdown
Owner

Here's a bug repro that shows a case where Rspack persistent cache is less efficient than webpack cache.

When some app JS files are code generated with fs.writeFile(), these files are always "re-loaded" by Rspack (but not by webpack) despite their content always being the same.

Not covered by this repro, but this also happens for files using loader this.addDependency("./dynamic.json"). I suspect the fs update time is used to invalidate cache entries, while webpack only uses the file content?

On Docusaurus, we have many files like that being code-generated, from JS to MDX documents outputted by community plugins. It would be great for us to have better persistent caching support for this scenario, like webpack does.


The test script yarn test will output:

###############################################
# USING WEBPACK
#############


##########
Bundle App start
- Loading src/entry.js
- Loading src/file.js
- Loading src/dynamicFile.js
Bundle App: 2.146s


##########
Bundle App start
Bundle App: 5.507ms


##########
Bundle App start
Bundle App: 4.528ms
###############################################
# USING RSPACK
#############


##########
Bundle App start
- Loading src/entry.js
- Loading src/file.js
- Loading src/dynamicFile.js
Bundle App: 2.032s


##########
Bundle App start
- Loading src/dynamicFile.js ===========> BAD
Bundle App: 1.009s


##########
Bundle App start
- Loading src/dynamicFile.js ===========> BAD
Bundle App: 1.006s

As you can see, the dynamicFile.js (code-generated) is always reloaded by Rspack, but not by webpack.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant