Road to ES6 (ES2015)


#1

Hi All,

I’m currently working on refactoring the entire client codebase to be ES6 compliant. Luckily everything was written in a way that this is a rather trivial task, so progress is fast (half-way as the time of writing) :slight_smile:

As of now this involves rewriting these parts:

  • Convert old fashioned namespaces to requirejs
  • Use const and let instead of var
  • Arrow functions where appropriate
  • General cleanup
  • Remove deprecated methods
  • Promises instead of callbacks (probably)
  • More modularized design
  • Better building
  • Node server code

This will be released under 2.1.0 and I’m contemplating removing the backward-compability I’ve written while developing this (this is just the namespacing, as in usage of OSjs.Foo instead of const Foo = require(...).

Another thing I’m looking at is using Webpack for all the bundling. Using Babel will allow for using non-standard features and paves the way for super easy upgrades for new standards.

All the work is done under https://github.com/os-js/OS.js/tree/upcoming/v2.1.0 but beware, this does not currently work out-of-the box with the standard build tools. But if you want to take a peak, it’s all there.

I don’t have any ETA on this, but I’ll update this post whenever I have a better picture.

If you want to read full list of changes, check out the drafted release announcement draft: UPDATE: Version bump - 2.1.0


#2

I’ve just completed refactoring the entire core client codebase :smile:

Going to make a workable testing release this weekend.


#3

I’m currently busy with a lot of work, so sadly I could not produce a test build. I’ll get back to this ASAP.

And for anyone that’s familiar with Babel. Is there some clever ways to decrease build times that’s not obvious from someone looking at the official documentation (disk cache helps a lot, but I was hoping there’d be something more I could do) ?


#4

I’ve rewritten the task system (now using Ygor) and made a complete Webpack implementation.

The branch now works properly (assuming you’re using the default package repo only) and you can compile all components of OS.js with Webpack and Babel.

I’m going to make proper writeup of all the changes, but thought y’all might find this interesting :slight_smile:

NOTE: To make branch compile: (cd node_modules; ln -sf ../src/build osjs-build). A proper npm package will be coming soon.


#5

Almost there now … I’d say about 80% done :slight_smile:

Here’s a list of changes in case anyone is interested (and yes, these are breaking):

  • Now using Webpack for building
  • Now using Ygor for tasking
  • New ‘osjs’ tool
  • Promises!
  • ES6+ (with Babel, or anything else you might want)
  • Reworked a lot of client modules
  • Removed Grunt entirely
  • Removed the old global OSjs namespace…
  • Replaced with OSjs.require()
  • Removed dist/vendor
  • Removed internal XHR stuff (replaced with axios)
  • Removed support for “simple package”
  • Removed a ton of deprecated stuff
  • Removed the automated installers
  • Changed configuration for builds
  • Changes to the templating system
  • Better package localization
  • VFS Mountpoint configuration changes
  • GUI Shemes have beed detached a bit, making it way easier to use custom GUI libraries (Like React)
  • GUI Schemes are now baked into bundles if in use
  • Class-ified all server modules (where appropriate)
  • A lot of cleanups
  • Squashing of some old bugs
  • General improvements
  • Splitting of modules
  • Change to esdoc (instead of jsdoc)
346 files changed, 31218 insertions(+), 44724 deletions(-)

There’s probably more changes, but my notes are pretty messy, so I’ll make it all good in the CHANGELOG when the time comes.

Now, I’ve created a module that can be imported to get almost complete backward-compability to make migration easier. I will make a complete guide for this later.

Build times might be longer now, but when using --watch this is almost a non-issue.

This also means new manuals (which I know quite a few people have been asking for). This time it will hopefully be a lot nicer to digest :smile:

Overall, I’m quite happy with the results so far and the conversion to ES6 was a way less painful then I imagined. 10/10!


#6

Just another quick update. I’ve pretty much finished all of the core components and packages now. The only things left are the unit tests and third party modules :slight_smile:

I’ve put up a checklist here: https://github.com/os-js/OS.js/issues/617

Oh, Webpack compilation process should now work properly for Windows users as well! Turns out there are some quirks regarding path resolution and casing of entry/output paths (“not an absolute path” and “multiple modules with names that only differ in casing” error messages).


#7

The Node server is now running on Express!

Things work pretty much the same, but this makes things easier to manage :smile:

The only breaking change here is how middleware is registered (as it now uses another pattern).


#8

First draft of docs are up :blush:


#9

Things are pretty much ready to go now!

But, before it goes official, I’ll have to update the extra packages provided on the “os-js” Github org account.

So, you should be able to start using it in the state it is now :slight_smile:

If anyone is up for some reading, please visit the manual (linked above) and give feedback.


#10

I’ve finished refactoring all of the extra package repos in Github ‘os-js’ account, so this means things will be released very soon.

These are the final pieces that needs to fall into place:

  • Do a final bug-pass
  • html-loader Webpack loader needs to make a release of the latest changes (currently using a github contrib git checkout)
  • Finish up documentation and the last tasks in https://github.com/os-js/OS.js/issues/617

The help get the first point done; I’ve deployed a pre-release on https://demo.os-js.org/ to monitor for a week to gather errors (using Sentry.io).


#11

You can also now read the drafted release announcement here: UPDATE: Version bump - 2.1.0

I’ll try to make the migration guide as complete as possible.