Open
Description
Description of the Issue
When using @lottiefiles/dotlottie-react
in a Webpack 4 project, the application crashes with a module parsing error. Despite configuring Webpack and Babel to handle the package, the build process fails when attempting to parse the module.
Expected Behavior
The Lottie animation should load and play correctly without any parsing errors.
Actual Behavior
The application crashes with a module parsing error:
ERROR in ./node_modules/@lottiefiles/dotlottie-react/dist/browser/index.js 21:9777
Module parse failed: Unexpected token (21:9777)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| - ArrayBuffer (dotLottie),
| - object (Lottie JSON).
> Received: ${typeof r}`);return;}l?(this._eventManager.dispatch({type:"load"}),B&&this.resize(),this._eventManager.dispatch({type:"frame",currentFrame:this.currentFrame}),this._render(),this._dotLottieCore.config().autoplay&&(this._dotLottieCore.play(),this._dotLottieCore.isPlaying()?(this._eventManager.dispatch({type:"play"}),this._animationFrameId=this._frameManager.requestAnimationFrame(this._draw.bind(this))):console.error("something went wrong, the animation was suppose to autoplay")),B&&this._canvas instanceof HTMLCanvasElement&&(this._renderConfig.freezeOnOffscreen&&i1.observe(this._canvas,this),this._renderConfig.autoRe...
Attempted Solutions
- Added WebAssembly experimental support in webpack config
- Tried different loaders for the package
Possible Solution
Could you please:
- Provide guidance on how to properly integrate this package with Webpack 4
- Consider providing a version that's compatible with Webpack 4 environments
- Add documentation for webpack 4 integration if there are special requirements
Steps to Reproduce
- Create or use an existing Webpack 4 project
- Install the packages:
npm install @lottiefiles/dotlottie-react
- Use the DotLottieReact component in a React component:
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
<DotLottieReact
src="https://lottie.host/63e43fb7-61be-486f-aef2-622b144f7fc1/2m8UGcP8KR.json"
loop
autoplay
/>
- Run the project with webpack-dev-server
P.S. I searched through issues for similar reports, but did not find anything
Metadata
Metadata
Assignees
Labels
No labels