-
-
Notifications
You must be signed in to change notification settings - Fork 782
Description
System Info
System:
OS: Windows 11 10.0.22631
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 8.69 GB / 15.79 GB
Binaries:
Node: 20.11.1 - C:\Program Files\nodejs\node.EXE
npm: 10.8.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Chromium (127.0.2651.74)
Internet Explorer: 11.0.22621.3527
npmPackages:
@rspack/cli: ^1.0.0 => 1.0.0
@rspack/core: ^1.0.0 => 1.0.0
@rspack/plugin-react-refresh: ^1.0.0 => 1.0.0
Details
When extracting the chunk sources in the build using source.source(), all sources are extracted as strings except for the runtime chunk, which returns the following object: {"type":"Buffer","data":[...]
Relevant code snippet:
new HtmlPlugin({
scriptLoading: 'module',
templateContent: ({ compilation }) => {
const assets = compilation.getAssets()
const pages = pagesManifest.map(({ chunk, path, title, data }) => {
const scripts = assets
.map(({ name }) => name)
.filter(name => new RegExp(`[/.]${chunk}\\.(.+)\\.js$`).test(name))
return { path, title, scripts, data }
})
if (production) {
const assetsWithSource = assets
.filter(({ name }) => /^scripts\/.+\.js$/.test(name))
.map(({ name, source }) => ({
url: `/${name}`,
-----------> source: source.source(),
parentPaths: pages.filter(({ scripts }) => scripts.includes(name)).map(({ path }) => path)
}))
writeFileSync(join(__dirname, 'public', 'assets.js'), JSON.stringify(assetsWithSource))
}
return htmlTemplate(pages)
}
}),
Reproduce link
https://github.com/theninthsky/client-side-rendering/tree/rspack
Reproduce Steps
- Clone https://github.com/theninthsky/client-side-rendering.git
- Switch to the
rspackbranch. npm i- In the
scripts/inject-worker-html.jsfile, comment line 29 which removes the helper filepublic/assets.js. npm run build- Open
public/assets.jsand look forruntime.
You'll see that only this chunk was extracted as an object.