web-infra-dev / rspack

The fast Rust-based web bundler with webpack-compatible API 🦀️
https://rspack.dev
MIT License
9.81k stars 566 forks source link

[Bug]: "asset/resource" module used to handle ".lottie"-animations works in dev-mode but breaks animation-file in production mode #5656

Closed fredrik-lindqvist closed 8 months ago

fredrik-lindqvist commented 9 months ago

System Info

System: OS: macOS 14.2.1, CPU: Apple M2 pro Memory: 16gb Shell: 5.9 - /bin/zsh Binaries: Node: 20.10.0 npm: 10.2.3 Browsers: Chrome 121.0.6167.160 Safari 17.2.1 npmPackages: @rspack/cli: 0.5.4 @rspack/core: 0.5.4 @dotlottie/player-component: 1.3.2 react: 18.2.0 react-dom: 18.2.0

Details

To handle import of animations (".lottie"-files ) in my app i use builtin "asset/resource" module. This works great in development mode and all animations are imported correctly. However when I switch to production mode, all imported animations break and can not be loaded correctly. If i switch to webpack 5 (version 5.89.0) all files are loaded correctly in both production and development mode.

Reproduce link

No response

Reproduce Steps

  1. setup "asset/resource" to handle ".lottie" files in rspack.config
  2. set mode to "production" in rspack.config
  3. import a ".dotlottie"-file to dot-lottie-player from @dotlottie/player-component
  4. animation wont work
  5. switch to development mode in rspack.config
  6. animation will work
fredrik-lindqvist commented 9 months ago

just downgraded to version 0.5.1 for @rspack/cli and @rspack/core: and then all dotLottie-animations work great in dev and production mode. Also tried version 0.5.2 and then the files break in production. Seems that the files loses their mimetype.

magic-akari commented 8 months ago

Same issue.

I attempted to address the issue by replacing the JSON path loading method with an inline JSON object(animationData), but the problem persisted. Therefore, I speculate that this issue is unrelated to the assets loader.

h-a-n-a commented 8 months ago

@fredrik-lindqvist Sorry I'm not able to reproduce. Would you please provide a minimal repo?

github-actions[bot] commented 8 months ago

Hello @fredrik-lindqvist, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction will be closed if no activities in 14 days.

magic-akari commented 8 months ago

Here is a minimal reproduction. This issue is related to optimization.minimize. rspack-lottie-1.0.0.tgz

fredrik-lindqvist commented 8 months ago

@magic-akari thanks for the repo. @h-a-n-a see comment above.

xc2 commented 8 months ago

thanks @magic-akari

it seems a swc_ecma_minifier related bug, and i've created an issue for this case.

https://github.com/swc-project/swc/issues/8651

please help with it