Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # 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
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
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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants