Skip to content

[Urgent] Unnecessary Bundle Hash Revving on Every Build #332

@raminjafary

Description

@raminjafary

The @nuxtjs/svg-sprite module is the cause of regenerating bundle file hashes on every build, even when no new SVG icons are added or modified. This behavior causes unnecessary cache invalidation and impacts performance. @farnabaz @harlan-zw

Current Behavior

  • Bundle file hashes change on every build
  • This occurs even when:
    • No new SVG files are added
    • No existing SVG files are modified
    • No configuration changes are made
  • Affects both development and production builds

Impact

  1. Cache Invalidation

    • Forces clients to download new assets on every deployment
    • Defeats the purpose of content hashing for caching
    • Increases bandwidth usage and load times
  2. Deployment Issues

    • CDN caches are invalidated unnecessarily
    • Increased deployment times
    • Higher storage costs due to duplicate assets

Expected Behavior

  • Bundle hashes should only change when:
    • New SVG files are added
    • Existing SVG files are modified
    • Module configuration is changed
  • Unchanged SVG files should maintain the same hash across builds

Reproduction Steps

  1. Clone the reproduction repository:

    git clone https://github.com/raminjafary/nuxt-svg-sprite-module-repro
    cd nuxt-svg-sprite-module-repro
  2. Install dependencies:

    pnpm install
  3. Run the build multiple times:

    pnpm build
    # Wait for build to complete
    pnpm build
    # Wait for build to complete
    pnpm build
  4. Observe that the bundle hashes change between builds even though no SVG files or configurations were modified

Workaround (Not available)

Removing the @nuxtjs/svg-sprite module resolves the issue. However, this is not an ideal solution as it removes the SVG sprite functionality entirely. A proper fix should be implemented in the module itself to prevent unnecessary hash revving.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions