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

[Bug]: Rspack persistent cache doesn't work for code-generated files #9413

Open
slorber opened this issue Feb 20, 2025 · 0 comments · Fixed by #9448 or #9503
Open

[Bug]: Rspack persistent cache doesn't work for code-generated files #9413

slorber opened this issue Feb 20, 2025 · 0 comments · Fixed by #9448 or #9503
Assignees

Comments

@slorber
Copy link

slorber commented Feb 20, 2025

System Info

Rspack 1.2.5

Details

When an app file to bundle is code-generated like that:

await fs.promises.writeFile(
  "./src/dynamicFile.js",
  `export const dynamic = 42`,
);

Then Rspack persistent cache will not work as expected: the JS loader will run again on subsequent app compilations.

This also happens when using this.addDependency("./dynamicFile.js")" in a loader.

This differs from Webpack 5 behavior which will cache the file and skip reloading it.

Reproduce link

slorber/rspack-cache-repro#1

Reproduce Steps

Check code on repro/PR: slorber/rspack-cache-repro#1

You can run it with yarn install && yarn test

Here's the console output printing the extra unwanted loader runs

###############################################
# 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

cc @hardfist @jerrykingxyz as requested on Discord

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