Skip to content

kwonoj/mf-asset-collision-test

Repository files navigation

Rspack 1.6.x Image Compression Bug Reproduction

This is a minimal reproduction case for image compression failures when using @rsbuild/plugin-image-compress with rspack 1.6.x.

Issue Description

After upgrading from rspack 1.5.3 to 1.6.2, image compression fails with:

  • JPEG files: Compress JPEG failed Any { .. }
  • PNG files: Optimize failed Invalid header detected; Not a PNG file

Environment

  • @rspack/core: 1.6.2 (fails) vs 1.5.3 (works)
  • @rsbuild/plugin-image-compress: 1.3.1
  • @napi-rs/image: 1.11.2 (transitive dependency)

Test Images

  • src/test.jpg - 259KB progressive JPEG
  • src/test.png - 681KB PNG

Both images are valid and verified with file command.

Reproduction Steps

Install dependencies

cd repro
npm install

This will install both rspack versions using npm aliases:

  • rspack-core-1.5 (rspack 1.5.3)
  • rspack-core-1.6 (rspack 1.6.2)

Test with rspack 1.5.3 (should work)

npm run build:1.5

Expected: Build succeeds ✅

Actual Result:

Rspack 1.5.3 compiled with 2 warnings in 5.94 s
Build completed!

Images are successfully compressed and output to dist/.

Test with rspack 1.6.2 (fails)

npm run build:1.6

Expected: Build fails with image compression errors ❌

Actual Result:

ERROR in × "d37f2fa28b53c09c.jpg" in "/path/to/repro" from Image Minimizer:
│ Compress JPEG failed Any { .. }

ERROR in × "211c9e79656758be.png" in "/path/to/repro" from Image Minimizer:
│ Optimize failed Invalid header detected; Not a PNG file

Rspack 1.6.2 compiled with 2 errors in 42 ms

Test both versions sequentially

npm run test:both

This will run both builds in sequence to demonstrate the difference.

Clean up

npm run clean

Implementation Details

This reproduction uses npm package aliases to install both rspack versions simultaneously:

  • rspack-core-1.5: Alias for @rspack/core@1.5.3
  • rspack-core-1.6: Alias for @rspack/core@1.6.2

The build scripts (build-1.5.js and build-1.6.js) are Node.js wrappers that:

  1. Explicitly require the correct rspack version using the alias
  2. Load the shared rspack.config.js
  3. Run the rspack compiler programmatically
  4. Report build status and errors

This approach ensures that each build uses the exact rspack version being tested.

Configuration

See rspack.config.js for the minimal configuration using ImageMinimizerPlugin with:

  • JPEG compression using @napi-rs/image
  • PNG lossless compression using @napi-rs/image

Expected vs Actual Behavior

Expected: Images should be compressed successfully in both rspack versions.

Actual:

  • rspack 1.5.3: ✅ Works correctly
  • rspack 1.6.2: ❌ Fails with cryptic Rust error messages

Notes

  • The error messages Any { .. } suggest Rust error details are being lost in the FFI boundary
  • The images are valid (verified with file and hexdump)
  • Disabling image compression allows the build to succeed
  • The issue affects both JPEG and PNG formats

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors