-
Notifications
You must be signed in to change notification settings - Fork 178
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]: Multiple identical SVGs generated with different hash #4610
Comments
Thank you for your feedback. If there is a reproduction repo that would be helpful. I looked at the changes in v1.1.0, web-infra-dev/rspack#8303 may be related to this issue, @ahabhgk can you take a look? |
Just tried again, but I'm not able to create a minimal repro :/ Will try to slim down our app as much as possible to see if I can get closer to the issue. |
Ha! I might have found something interesting. @chenjiahan , @ahabhgk const iconModule = await import(`my-app/icons/${options.sourceFolder}/${iconName}.svg`); Temporarily removing this makes the duplicate icons disappear. I was able to reproduce it here: https://codesandbox.io/p/github/rspack-contrib/rsbuild-codesandbox-example/csb-4xtsz4/draft/inspiring-microservice?file=%2Fsrc%2FApp.jsx%3A3%2C1 where I load the same icon twice (statically and dynamically): import "./App.css";
import { ReactComponent as Add } from "./Add.svg";
const App = () => {
useEffect(() => {
const iconName = "Add";
import(`./${iconName}.svg`).then((x) => console.log("x", x));
}, []);
return (
<div className="content">
<h1>Rsbuild with React</h1>
<Add />
<Test />
<p>Start building amazing things with Rsbuild.</p>
</div>
);
};
export default App; Running the build will show that the icon is being generated twice (with different hash): ![]() I guess that the fact that an SVG (or an asset, really) is imported dynamically influences the hashing logic? |
When using cc @chenjiahan |
@ahabhgk Got it. I will try to change the hash function of |
Version
Details
Long time no see! Hello team.
After upgrading from
@rsbuild/core@1.0.19
to@rsbuild/core@1.2.2
our build process started creating duplicate SVGs with the same content but different contenthash. By trying different versions, I was able to pinpoint that the issue was introduced in@rsbuild/core@1.1.0
.Our SVG output in
@rsbuild/core@1.0.19
:Our SVG output in
@rsbuild/core@1.1.0
(notice multipleapp.v0.Activity.[HASH].svg
, etc.):See for example the duplicate
app.v0.Activity.[HASH].svg
. In both cases, the content is identical:Verified via CLI:
We tried updating the various plugins, manually changing various setting (like the contenthash setting it to
[contenthash:16]
for example), and more, but with no success.Both SVGs are used across generated JS files.
Stripped down version of the config that still has the issue:
Reproduce link
No repro (yet)
Reproduce Steps
It's hard for us to identify what's causing it, so we don't have a minimal reproduction yet. Any idea on what might be triggering this or that has been introduced that could cause this? Happy to create a repro if I can find a way to isolate the issue. Thanks!
The text was updated successfully, but these errors were encountered: