Jump to content

Pixi.js ES6


powerfear
 Share

Recommended Posts

Hello, I've been working on a ES6 version of Pixi.js and I thought I'd share it in case anyone is interested in using it.

 

It's currently updated to the latest commit of the dev branch as of this post. I've been updating it for a while and I intend to continue doing so, at least for a little while.

 

You can get it right here: https://github.com/powerfear/pixijs-es6

 

You can directly use the src in the "src" folder with whatever setup you like to convert it to ES5.

 

There is also a commonjs folder which basically contain the ES6 source transpiled to ES5 + Commonjs for the import. This can be used with browserify, pure-cjs or similar commonjs build tools.

 

For an example of a possible workflow you can checkout: https://github.com/powerfear/es6-workflow

 

I am basically using https://github.com/square/es6-module-transpiler for final builds while I convert the import to commonjs and use https://github.com/RReverser/pure-cjs during development as it is about 7 times faster to build in my case.

 

I am still working on improving and simplifying the workflow. If you have suggestions feel free to leave them here, send me pull request, issues.

Link to comment
Share on other sites

 

It's currently updated to the latest commit of the dev branch as of this post. I've been updating it for a while and I intend to continue doing so, at least for a little while.

Are you doing this manually, or is it automated?

Link to comment
Share on other sites

 

Are you doing this manually, or is it automated?

 

It is not automated, this is not an exact copy of PIXI converted to ES6. For instance I could've kept the global PIXI object, but then there wouldn't be any differences then using the current version of PIXI. The point of this is not to use a global object but rather to use the ES6 import system. To get this to work I also had to make few other changes to PIXI. PIXI had quite a couple of circular dependencies and I had to resolve them which meant moving some code around to different files to solve them. All of those changes made automation not a straightforward option. PIXI actually doesn't receive that many large changes that frequently, I am simply manually applying the commit which usually consist of few lines of codes.

Link to comment
Share on other sites

So you're just using the es6 "module" system, I'll suggest to use es6-module-transpiler and you don't need to modify even one line of PIXI itself. The es6-module-transpiler simple compiles es6 module into cjs/amd, and then you can use some cjs/amd loader to make it work.

I made a simple slush generator for Phaser (https://www.npmjs.org/package/slush-phaser-project), using almond.js to load compiled amd modules and it should be very easy to change to support PIXI.

Link to comment
Share on other sites

So you're just using the es6 "module" system, I'll suggest to use es6-module-transpiler and you don't need to modify even one line of PIXI itself. The es6-module-transpiler simple compiles es6 module into cjs/amd, and then you can use some cjs/amd loader to make it work.

I made a simple slush generator for Phaser (https://www.npmjs.org/package/slush-phaser-project), using almond.js to load compiled amd modules and it should be very easy to change to support PIXI.

No I completely converted PIXI itself to use es6 module and classes internally. Also I am using es6-module-transpiler.

Link to comment
Share on other sites

No I completely converted PIXI itself to use es6 module and classes internally. Also I am using es6-module-transpiler.

That's really cool, sorry I miss reading a few lines :P

I'll checkout your sample workflow which looks amazing. I recommend to create a slush generator to make life easier.

One more question, what are the benefits of using cjs instead of amd, or just your choice?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...