Skip to content

Generated files on disk have different file hash than Webpack-reported assets #72285

Open
@mauron85

Description

@mauron85

Link to the code that reproduces this issue

https://github.com/mauron85/nextjs-webpack-assets

To Reproduce

  1. create plain nextjs app or pull example from https://github.com/mauron85/nextjs-webpack-assets
  2. 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;
  },
};
  1. run npm run build
  2. 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."

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.create-next-appRelated to our CLI tool for quickly starting a new Next.js application.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions