pixijs / particle-emitter

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

`this.PIXI = this.PIXI || {};` can't run in ES6 & `strict mode` #100

Closed finscn closed 3 years ago

finscn commented 5 years ago

the struct of pixi-particles dist file is like this :

this.PIXI = this.PIXI || {};
(function (exports, pixi) {
    'use strict';

// ... ...

}(this.PIXI.particles = this.PIXI.particles || {}, PIXI));

In es6 & es5 with strict mode , the this is undefined .

So I think you should refactor the build scripts of pixi-particles.

finscn commented 5 years ago

image

this are some information about this .

but I know nothing about rollup , So I don't know how to modify it .

andrewstart commented 5 years ago

package.json already has an entry for module, so Rollup should automatically pull in an ES6 version of the library. You'll need to look into why you are pulling in the dist/pixi-particles.js version instead. The first thing you should check is to make sure that you are importing the pixi-particles library from node_modules, rather than dist/pixi-particles.js directly.

finscn commented 5 years ago

I forked pixi-particles , and I want to use my forked pixi-particles in ES5 with "use strict" . And whatever , the this.PIXI is a bad code.

I've used pixi-filters pixi-projection pixi-tilemap
in my project .

When I include them , I don't meet any problem. But pixi-particles puzzles me.

Could you do something to pixi-particles like pixi-filters , pixi-projection, pixi-tilemap ?

andrewstart commented 5 years ago

The main, bundle, and module values in package.json are actually what Pixi.js v5 uses, so I am trusting them that it is the right thing.

finscn commented 5 years ago

When I use "use strict" , and mix my js file and pixi.js into one file (named all-in-one.js),

the this.PIXI can't run , the error is this is undefined .

andrewstart commented 5 years ago

You need to change your Rollup configuration to pull in the module export instead of dist/pixi-particles.js. This may involve just removing existing configuration that specifies that path, if you have it present.