pixijs / pixijs

The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.
http://pixijs.com
MIT License
43.76k stars 4.77k forks source link

Bug: bump version of eventemitter3 to 5 in @pixi/utils #9349

Open redexp opened 1 year ago

redexp commented 1 year ago

Current Behavior

methods of EventEmiter not visible in Container eventemitter3 of version 4 exports EventEmiter class as export = EventEmitter; (not as export default) and in @pixi/utils it imported as export { default as EventEmitter } from 'eventemitter3'; which is wrong and produces bugs like #7505 #7865

Expected Behavior

methods of EventEmiter are visible in Container class

Steps to Reproduce

import {Container} from "pixi.js";

const c = new Container();
c.on // property not exists in Container

Environment

Possible Solution

bump eventemitter3 to version 5 - it's right next version after 4.0.7 and focused only on ESM support

or change code to export { EventEmitter } from 'eventemitter3'; without default

Additional Information

No response

SuperSodaSea commented 1 year ago

Are you using esModuleInterop: true in tsconfig.json?

redexp commented 1 year ago

Are you using esModuleInterop: true in tsconfig.json?

I'm not, because I'm not using typescript in my project, but my IDE goes down to this error and can't resolve any EventEmiter methods. Also I seeing repeating issues about same problem, which can be solved easily from your side without needing users to know about any typescript configs

redexp commented 1 year ago

@SuperSodaSea I can create PR

SuperSodaSea commented 1 year ago

@redexp Feel free to create the PR :)

Pauan commented 1 year ago

I just ran into this bug with a completely normal vanilla JavaScript + Rollup setup.

Here is a gist of my code. Download it as ZIP, then do yarn install and then yarn build. You will get this error:

[!] RollupError: "default" is not exported by "node_modules/eventemitter3/index.js", imported by "node_modules/@pixi/utils/lib/index.mjs".
https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
node_modules/@pixi/utils/lib/index.mjs (3:9)
1: import './settings.mjs';
2: export { isMobile } from '@pixi/settings';
3: export { default as EventEmitter } from 'eventemitter3';
            ^
4: export { default as earcut } from 'earcut';
5: export { url } from './url.mjs';

Unfortunately this makes Pixi completely unusable with ES6-compliant bundlers like Rollup.

Dunnings commented 3 months ago

This issue has kept rearing it's ugly head in multiple projects I've worked on. The exports of eventemitter3 are inherently f**ked. esModuleInterop true or false, it doesn't matter

MeirionHughes commented 1 month ago

I'm getting this with rollup trying to make a worker.

pixi.js@8.3.4 rollup@4.21.2

14:13:23 [vite] Internal server error: ../../node_modules/pixi.js/node_modules/eventemitter3/index.mjs (1:7): "default" is not exported by "../../node_modules/pixi.js/node_modules/eventemitter3/index.js", imported by "../../node_modules/pixi.js/node_modules/eventemitter3/index.mjs".

I'm importing pixi into a webworker via rollup-plugin-worker, the config for which is:

webworker({
  plugins: [
    nodeResolve(),
    importAsString({ include: ["**/*.glsl"] })
  ] as Rollup.Plugin[],
}),

nodeResolve({browser: true}) has the same result

Anyone have a workaround?