pixi-react icon indicating copy to clipboard operation
pixi-react copied to clipboard

Bug: ReferenceError: Worker is not defined

Open Vlad7is7lav opened this issue 1 year ago • 1 comments

Current Behavior

When I start (npm run dev) in next.js I get the error ReferenceError: Worker is not defined at Object. (S:\My Projects\spores\node_modules@pixi\assets\lib_virtual\checkImageBitmap.worker.js:22:30)

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/react version: e.g. 7.0.0
  • pixi.js version: e.g. 7.1.0
  • React version: e.g. 18.0.0
  • ReactDOM version: 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

Vlad7is7lav avatar Mar 02 '24 11:03 Vlad7is7lav

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

alanwong22 avatar Mar 05 '24 14:03 alanwong22

Hey, this should be fixed in the next release of pixi

https://github.com/pixijs/pixijs/pull/10227

Zyie avatar Mar 12 '24 09:03 Zyie

@Zyie - is this fix only going to be in v8? I was hoping to avoid an upgrade right now.

morses-code avatar Mar 12 '24 12:03 morses-code

Sorry, should have clarified, it will be fixed in the next v7 release We already have the fix in v8

Zyie avatar Mar 12 '24 13:03 Zyie

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

Zyie avatar Apr 08 '24 14:04 Zyie