Closed RabbitShare closed 1 month ago
Hello @RabbitShare, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction
will be closed if no activities in 14 days.
You can try disabling splitChunks and see if the problem still exists, and also remove hashes in your output filenames. When an entry chunk is splitted to mutiple and rendered into html script tags by html plugin, the generated html will not be updated without reloading the page even if the chunk is splitted again.
Thanks for variants, but it's not works for me. Here is repro demo https://github.com/RabbitShare/rspack-test. Repo has dist1 and dist2. dist1 build with
export const Test = () => {
return (
<div>
<h1>Test</h1>
</div>
);
};
output is:
"use strict";
(self.webpackChunkrspack_test = self.webpackChunkrspack_test || []).push([
["568"],
{
58: function (e, s, t) {
t.r(s),
t.d(s, {
Test: function () {
return n;
},
});
var c = t(250);
let n = () =>
(0, c.jsx)("div", { children: (0, c.jsx)("h1", { children: "Test" }) });
},
},
]);
//# sourceMappingURL=568.js.map
dist2 build with
export const Test = () => {
return (
<div>
<h1>Test1</h1>
</div>
);
};
output:
"use strict";
(self.webpackChunkrspack_test = self.webpackChunkrspack_test || []).push([
["568"],
{
58: function (e, s, t) {
t.r(s),
t.d(s, {
Test: function () {
return n;
},
});
var c = t(250);
let n = () =>
(0, c.jsx)("div", {
children: (0, c.jsx)("h1", { children: "Test1" }),
});
},
},
]);
//# sourceMappingURL=568.js.map
As you see 568 from dist1 not equal to 568 from dist2.
For reproduction:
Expected behavior: Chunk from dist2 has another name
Thanks for variants, but it's not works for me. Here is repro demo RabbitShare/rspack-test. Repo has dist1 and dist2. dist1 build with
export const Test = () => { return ( <div> <h1>Test</h1> </div> ); };
output is:
"use strict"; (self.webpackChunkrspack_test = self.webpackChunkrspack_test || []).push([ ["568"], { 58: function (e, s, t) { t.r(s), t.d(s, { Test: function () { return n; }, }); var c = t(250); let n = () => (0, c.jsx)("div", { children: (0, c.jsx)("h1", { children: "Test" }) }); }, }, ]); //# sourceMappingURL=568.js.map
dist2 build with
export const Test = () => { return ( <div> <h1>Test1</h1> </div> ); };
output:
"use strict"; (self.webpackChunkrspack_test = self.webpackChunkrspack_test || []).push([ ["568"], { 58: function (e, s, t) { t.r(s), t.d(s, { Test: function () { return n; }, }); var c = t(250); let n = () => (0, c.jsx)("div", { children: (0, c.jsx)("h1", { children: "Test1" }), }); }, }, ]); //# sourceMappingURL=568.js.map
As you see 568 from dist1 not equal to 568 from dist2.
For reproduction:
- pull repo
- npm ci
- git checkout v1.0.0
- npm run build
- save dist artifact with another name (dist1 in repo, but you can use another). Optional npx prettier --write [new dist name]
- git checkout v1.0.1
- npm run build
- save dist artifact with another name (dist2 in repo, but you can use another). Optional npx prettier --write [new dist name]
Expected behavior: Chunk from dist2 has another name
Can not find v1.0.0 and v1.0.1 in tags or branches, have you pushed them to github?
The chunk id will not change if the module relationships are not changed. Changing code of a module can only affect the content hash of the chunks which contains the changed module.
If you set chunkFilename
to [id].js
, then the runtime will generate url from chunk id directly. If you set chunkFilename
to [id].[contenthash].js
, then the runtime will generate a map from chunk id to chunk file name.
According to the image you reported before, it seems that the runtime used the old chunk map and try to load the new chunk which content hash had changed. But the old chunk map is in the main chunk which loaded by html plugin. And if the main chunk also has content hash, the html need to be refreshed after every change.
In your repro, there is no content hash, so the chunk filename will only contains the chunk id which will not always change like the content hash.
Hi, added hashing https://github.com/AndreyGladkov/rspack-test/blob/main/rspack.config.ts#L16(checked for the following types: chunkhash
, fullhash
. for the value contenthash
the hash changes as expected)
I'm added SubComponent
export const SubComponent = () => {
return (
<div>
<h1>Test1</h1>
</div>
);
};
and building to dest1:
"use strict";
(self.webpackChunkrspack_test = self.webpackChunkrspack_test || []).push([
["300"],
{
88: function (s, e, t) {
t.r(e), t.d(e, { Test: () => r });
var c = t("250");
let h = () =>
(0, c.jsx)("div", {
children: (0, c.jsx)("h1", { children: "Test1" }),
}),
r = () =>
(0, c.jsxs)("div", {
children: [
(0, c.jsx)("h1", { children: "Test2" }),
(0, c.jsx)(h, {}),
],
});
},
},
]);
//# sourceMappingURL=300.5ba29289df5157a4ca31.js.map
I'm changed SubComponent:
export const SubComponent = () => {
return (
<div>
<h1>Test2</h1>
</div>
);
};
and building to dest2
"use strict";
(self.webpackChunkrspack_test = self.webpackChunkrspack_test || []).push([
["300"],
{
88: function (s, e, t) {
t.r(e), t.d(e, { Test: () => r });
var c = t("250");
let h = () =>
(0, c.jsx)("div", {
children: (0, c.jsx)("h1", { children: "Test2" }),
}),
r = () =>
(0, c.jsxs)("div", {
children: [
(0, c.jsx)("h1", { children: "Test2" }),
(0, c.jsx)(h, {}),
],
});
},
},
]);
//# sourceMappingURL=300.5ba29289df5157a4ca31.js.map
The content changes, but the chunk hashes do not:
dist1/300.5ba29289df5157a4ca31.js is equals to dist2/300.5ba29289df5157a4ca31.js
@LingyuCoder hi, please look at the message above
There is a bug while using [chunkhash]
in output.chunkFilename
with optimization.concatenateModules
which is enabled by default in production
mode. I will try to fix it
System Info
System: OS: macOS 15.0 CPU: (10) arm64 Apple M1 Pro Memory: 139.61 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.16.0 - ~/.nvm/versions/node/v20.16.0/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 10.8.1 - ~/.nvm/versions/node/v20.16.0/bin/npm Browsers: Chrome: 128.0.6613.138 Firefox: 128.0.2 Safari: 18.0
Details
After build some files dosen't change his hashes, but links to builded files changed. Sorry for bad quality. It's our user's screenshot
Rspack trying to request chunk /js/5488.undefined.js. But this chunk broken. I think it's because rspack not change file hash if change only link to another chunk (i don't know how it works, perceive link as abstraction) (comparison of two chunks with same names between different builds)
webpack build normally.
rspack.config.ts
Reproduce link
No response
Reproduce Steps