-
Notifications
You must be signed in to change notification settings - Fork 249
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
issue/2647 add es6-8 support #2648
Conversation
tested various (easy) features from ES6-ES8: arrow function, array.filter, Object.assign, Object.values, padStart, async/await. All successful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
👀 |
can we hold off on merging this and #2652 until I've had a chance to do a release of what's currently in master (plus maybe one or two other things)? |
of course, we still don't have the requisite +1s, so you should be safe regardless |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the following in the Chrome console:
DevTools failed to parse SourceMap: http://localhost:9001/libraries/backbone-min.map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implicit +1 since was using it in issue/2647-2
branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works 👌
Awaiting a framework release and a few more reviews - just to be safe. |
Hi @oliverfoster, why exactly does |
The CourseModel inherits from the MenuModel because CourseModel is both a menu and a contentobject (from the router's perspective), as well as the root container of the course content (no _parentId or siblings), the home of the _globals namespace (grunt extends the model, views and handlebars reference) and the target for plugin attributes (schemas define these), etc. It'll make simplifying the router a little easier later. The router should just manage contentObjects + bespoke plugin routes. The inheritance was: Now it's: To match: It means we don't have to lookup the _type=[menu/page/course], we can just check if it's a ContentObjectModel instance and the router is then allowed to render it straight into the wrapper. Otherwise if the thing the router has been asked to render is not a ContentObjectModel, we need to find the first ancestor ContentObjectModel, render that and scroll to the specified id. I want to remove hard-coded references to plugin types and this is an easy win without changing anything too complicated, but at the same time it also allows us to simplify some really unnecessarily complicated code. Plus it doesn't break anything 👍 and any subsequent behaviour we attach to the ContentObjectModel or the MenuModel won't have to be duplicated into the CourseModel. Like the introduction of Stuff like this can be removed, moved or simplified without any impact on behaviour but with strides in clarity: |
This pull request is ready for final +1s |
Hi Oliver, |
fixes #2647
This pr allows us to use a large amount more ES6, ES7 and ES8, such as: classes to replace and extend from backbone ones, arrow functions, spread operators, async/await, Object.assign, Array.filter etc. all of which should work in IE11 given these changes.
Limitations
We're still using requirejs to bundle modules so we won't be able to use ES6 module import/export directives yet.
As requirejs uses Esprima to turn JavaScript into AST, the compilation process is limited to whatever Esprima can parse, it claims full support for ES8. This discounts some newer features of ECMAScript, such as ES9 object property spreading:
requirejs will error at compile time with warnings for unsupported syntax, like so:
Function argument spreading works as expected.
Changes
preinitialize
function to model, view, collection, etcpreinitialize
functionpreinitialize
allows es6 classes to setup events, defaults etc before the backboneinitialize
function callsNotes
I was thinking we could add this to version 5 to provide some backwards compatibility for plugins which will be updated in v6+.
If we convert backbone classes to es6 classes in the core (we definitely should do this), then we will need to define constructor properties as static getters:
Testing
The PR #2651 has been accepted and merged into this one such that this PR contains client-side ES6-8 and updated build tools.