pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
793 stars 125 forks source link

crash when using pixi v5 as a ES6 module #94

Closed getkey closed 5 years ago

getkey commented 5 years ago

The ES6 module build of Pixi v5 (I tried with the RC2) no longer exports the PIXI global variable (see https://github.com/pixijs/pixi.js/commit/14fa305ada60fc631cb4a07d78d8aae0d820c969).

When using the ES6 module build of Pixi v5, pixi-particles throws pixi-particles requires pixi.js to be loaded first because it expects Pixi to be global.

The obvious solution would be making Pixi a peer dependency, but then the browser build will break. I think the way to go about this it to make 2 builds:

andrewstart commented 5 years ago

I've been working on this in my spare time for a few days, updating the build process to use the same one as v5. I now have it at a point where imports and global namespaces work for both v4 and v5, with manual tests to prove it. I am taking this opportunity to fix some other oddities in the documentation process, so it'll be a little bit before I make a release (hopefully before or shortly after the official v5 release).

andrewstart commented 5 years ago

New release! v4.0.0 should fix all of this.

getkey commented 5 years ago

Thanks, great work! :smile:

In the ES export, I'm getting an error, because it tries to import ticker wich is not exported by pixi v5. Looks like the ES export can't support both v5 and v4.

> yarn watch
yarn run v1.13.0
$ rollup -c --watch
NODE_ENV: undefined, watch: true
[!] Error: 'ticker' is not exported by node_modules/pixi.js/lib/pixi.es.js
https://rollupjs.org/guide/en#error-name-is-not-exported-by-module-
node_modules/pixi-particles/lib/pixi-particles.es.js (8:55)
 6:  * http://www.opensource.org/licenses/mit-license
 7:  */
 8: import { BLEND_MODES, Point, Texture, Sprite, VERSION, ticker as ticker$1, Ticker, Rectangle, Circle, settings } from 'pixi.js';
                                                           ^
 9: 
10: /**
Error: 'ticker' is not exported by node_modules/pixi.js/lib/pixi.es.js
    at error (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:3601:30)
    at Module.error (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:14470:9)
    at handleMissingExport (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:14397:21)
    at Module.traceVariable (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:14739:17)
    at ModuleScope.findVariable (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:13408:37)
    at BlockScope.ChildScope.findVariable (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:4248:67)
    at MemberExpression.bind (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:12369:47)
    at AssignmentExpression.NodeBase.bind (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:10242:23)
    at AssignmentExpression.bind (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:10998:31)
    at ExpressionStatement.NodeBase.bind (/mnt/data/devel/xplozzle/node_modules/rollup/dist/rollup.js:10242:23)

1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
andrewstart commented 5 years ago

Ugh, it would be fine, if rollup didn't transform my imports for the ES export. This requires some investigation.

andrewstart commented 5 years ago

4.0.1 is published and should fix this.

getkey commented 5 years ago

Thanks, it works! :tada: