Description
Link to the code that reproduces this issue
https://github.com/mauron85/nextjs-webpack-assets
To Reproduce
- create plain nextjs app or pull example from https://github.com/mauron85/nextjs-webpack-assets
- add simple asset log plugin
// next.config.js
module.exports = {
webpack: (config, { webpack }) => {
config.plugins.push({
apply: (compiler) => {
compiler.hooks.compilation.tap("LogFinalFilenamesPlugin", (compilation) => {
compilation.hooks.processAssets.tap(
{
name: "LogFinalFilenamesPlugin",
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE,
},
() => {
const assetNames = Object.keys(compilation.assets);
console.log("Final asset filenames:", assetNames);
}
);
});
},
});
return config;
},
};
- run npm run build
- compare file names in .next\static\chunks\pages[sessionId] vs what plugin reported
Current vs. Expected behavior
When building a Next.js application, the assets listed by Webpack (such as those logged by plugins like FileListPlugin or available in Webpack stats) have different hashes in their filenames compared to the files actually written to the .next/static folder on disk. This creates a mismatch between the assets reported by Webpack and those available on disk after the build process completes, impacting other webpack plugins eg. bug like microsoft/azure-devops-symbols#253
The filenames for assets reported by Webpack should match those generated on disk in the .next/static folder, including any appended hash values for cache busting.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Enterprise
Available memory (MB): 32436
Available CPU cores: 8
Binaries:
Node: 20.17.0
npm: 10.8.2
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.0.2 // Latest available version is detected (15.0.2).
eslint-config-next: 15.0.2
react: 19.0.0-rc-02c0e824-20241028
react-dom: 19.0.0-rc-02c0e824-20241028
typescript: 5.6.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
create-next-app
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
"The mismatch between filenames on disk and Webpack asset names is causing issues with other Webpack plugins. For instance, when using AzureDevOpsSymbolsPlugin, this discrepancy results in duplicated sourceMappingURL entries in production builds, rendering them unusable across all browsers."