Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to ES6 #272

Closed
xeolabs opened this issue Aug 30, 2018 · 5 comments
Closed

Convert to ES6 #272

xeolabs opened this issue Aug 30, 2018 · 5 comments

Comments

@xeolabs
Copy link
Owner

xeolabs commented Aug 30, 2018

Also use rollup, which will build xeogl as an ES6 module in build/xeogl.module.js, and as a UMD module in build/xeogl.js.

Doing the conversion in this branch: https://github.com/xeolabs/xeogl/tree/es6

  • Convert xeogl core to ES6
  • Configure rollup to build library as ES6 module and UMD module
  • Convert "extras" example components to ES6 classes
  • Use gulp instead of grunt
@MichaelDeBoey
Copy link

@xeolabs Are you planning on releasing this as an npm package too btw?
The unofficial one (https://www.npmjs.com/package/@wikifactory/xeogl) is still at v0.7.2, so it would be nice to have an official package published 🙂

@xeolabs
Copy link
Owner Author

xeolabs commented Aug 30, 2018

@MichaelDeBoey yip will do!

@xeolabs
Copy link
Owner Author

xeolabs commented Sep 9, 2018

The xeogl ES6 branch is now largely working if anyone needs to preview it. Will merge into master when I've updated the docs. Feedback is super welcome, please comment in this issue if you have any questions or feedback.

Change docs (WIP): https://github.com/xeolabs/xeogl/wiki/Updates-in-xeogl-v0.9
Repo branch: https://github.com/xeolabs/xeogl/tree/es6

Rollup is building two versions of xeogl: a UMD module and an EC6 module, in the build dir: https://github.com/xeolabs/xeogl/tree/es6/build

The UMD version should work just like v0.8, ie. with a global xeogl namespace.

@xeolabs
Copy link
Owner Author

xeolabs commented Sep 9, 2018

BTW, the main breaking API change with this ES6 upgrade is that the default Scene is no longer settable/gettable via a property on the xeogl namespace - now that's supported with a pair of setter and getter methods.

In v0.8 (EC5), it was:

// Get default scene, internally creating first if needed
var theDefaultScene = xeogl.scene; 

// Set the default scene
xeogl.scene = new xeogl.Scene({... });

// Subsequently created components will be within xeogl.scene
// if no scene is explicitly provided for them.

Reason

In the EC6 conversion, xeogl.js is the rollup "input" file, which effectively assembles the xeogl namespace via a bunch of exports.

Unfortunately, you can't export an object property, the way xeogl.scene was defined in v0.8.

Therefore, I was forced to replace that with setDefaultScene() and getDefaultScene() methods, which can be exported.

Accordingly, I needed to update a few examples that referenced that default Scene.

Maybe there's something I missed - some hacky thing I can do to keep that dynamic xeogl.property?

Not sure, if anyone has tips let me know!

@xeolabs
Copy link
Owner Author

xeolabs commented Sep 12, 2018

I've just released v0.9, which converts xeogl to #ECMA6 - https://github.com/xeolabs/xeogl/wiki/Updates-in-xeogl-v0.9

Next step: publish the core library as an npm package, along with some of the non-core components like GLTFModel. Just got some reading to do on all of that first.

@xeolabs xeolabs closed this as completed Sep 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants