Bug: ReferenceError: Worker is not defined
Current Behavior
When I start (npm run dev) in next.js I get the error
ReferenceError: Worker is not defined
at Object.
I tried to change next.config.js with next code
if (!isServer) { config.module.rules.push({ test: /pixi\.js$/, use: [ { loader: 'worker-loader', options: { inline: true, fallback: false }, }, ], }) }
but it didn't help me.
How can I solve this problem? Please, help me anybody :(
Expected Behavior
Run application
Steps to Reproduce
`import { FC, useState, useEffect } from 'react' import s from './GamePage.module.scss' import { Stage, Text, Graphics } from "@pixi/react";
interface GamePage {}
export const GamePage: FC<GamePage> = () => {
const draw = (g:any) => { g.beginFill(0x0033cc, 1) g.drawRect(250, 150, 150, 120) g.endFill() }
return (
<div className={s.wrapper}>
<div className={s.main}>
<Stage
width={400}
height={400}
renderOnComponentChange={true}
options={{ antialias: true, backgroundAlpha: 0 }}
/>
<Graphics draw={draw} />
</div>
</div>
) }`
Environment
@pixi/reactversion: e.g. 7.0.0pixi.jsversion: e.g. 7.1.0Reactversion: e.g. 18.0.0ReactDOMversion: e.g. 18.0.0- Browser & Version: e.g. Chrome 108
- OS & Version: e.g. Ubuntu 22.04
- Running Example: e.g. https://pixiplayground.com/
Possible Solution
No response
Additional Information
No response
Same error
@pixi/react: 7.1.0 pixi.js: 7.2.4 react: 18.2.0 react-dom: 18.2.0
Chrome 122.0.6261.94
Hey, this should be fixed in the next release of pixi
https://github.com/pixijs/pixijs/pull/10227
@Zyie - is this fix only going to be in v8? I was hoping to avoid an upgrade right now.
Sorry, should have clarified, it will be fixed in the next v7 release We already have the fix in v8
Hey, pixi 7.4.2 should have solved this
https://github.com/pixijs/pixijs/releases/tag/v7.4.2
let me know if you still have issues and we can reopen this one