Skip to content
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

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

Open
mauron85 opened this issue Nov 4, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application.

Comments

@mauron85
Copy link

mauron85 commented Nov 4, 2024

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."

@mauron85 mauron85 added the bug Issue was opened via the bug report template. label Nov 4, 2024
@github-actions github-actions bot added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application.
Projects
None yet
Development

No branches or pull requests

1 participant