Hi everybody,
If you are a community developer and your plugin includes Javascript, then you will probably want to read all of this post.
Normally we try very hard to not make any changes to generated output (JS, and CSS) from build tools because we know that it can really impact our community developers. In fact, the last time that we made any substantial change to compiled javascript was in MDL-62497 when we introduced support for ES6-style Javascript in Moodle 3.8.
Unfortunately there are times that we must make such changes, and when we do so we do try to consider how this impacts upon you. We know that many of you like to have a single version of your plugin covering a wide range of Moodle versions, and that changes like this may upset your own testing and tooling.
Recently we encountered a bug in the mangle
feature of the minification plugin that we use. This plugin is a part of babel/minify, which has unfortunately not seen any updates in the past 18 months and its last release was over two years ago. With countless issues awaiting review or triage there we are not hopeful that it will be resolved soon. Essentially this mangle behaviour is intended rename internal variable and function names to much shorter versions which are consistently used - for example a
, b
, c
, etc. Unfortunately we have found examples in more complex code where this is done incorrectly, and we cannot easily determine when/where this may happen.
Thankfully we can work around this behaviour by disabling the mangle feature of babel-minify, but doing so will lead to changes in our built output.
Given the nature of this bug I am proposing that we backport the change to all supported versions of Moodle (currently 3.9, 3.10, 3.11, 4.0). This is something that we normally do when we update the version of NodeJS that we support, and in other circumstances too. This will mean that there will be a one-off change to your build for stable versions of Moodle. This is an existing part of our processes.
Since we are required to update the built output, I am also proposing that we update to the latest LTS version of NodeJS - LTS Gallium which was released in November. Again, this is a normal part of our release process and we can take the opportunity to update a number of our NodeJS dependencies including babel, and eslint. These changes also generate changes in the output of both AMD and YUI compiled javascript but as we are already making changes to this output, there will be no additional impact.
However I am also proposing that, while we are making such changes, and given Moodle 4.0 has a number of larger feature changes that already impact many plugins, that we should change the list of supported browsers for Moodle 4.0 to remove support for Internet Explorer.
This is a decision that we originally proposed 18 months ago and it was agreed that we would drop support for IE11 from 3.9, and remove the polyfills and other tooling that allowed the support of IE11 from Moodle 3.10 onwards. We never actually removed these polyfills in 3.10 as we wanted to avoid modifying the compiled JS output but we are able to now. You can see MDLSITE-6109 for the detail of this discussion.
Now that we are required to make a change to compiled JS, it seems sensible to make this change at the same time.
I'm also proposing that we drop support for a very old version of the Android browser (4.4.4) whose last release was in June 2014 and which has very minimal usage.
By dropping support for both of these older browsers, we will stop injecting most of the support polyfills that we currently have into the code and you will be able to natively use and debug features like Promises, async, generators, for...of, and many others natively. This has a hugely positive impact upon the way in which you are able to debug JS code and follow sourcemaps.
Unfortunately this change will mean that if you run grunt
on master/4.0+ and use that code on older versions of Moodle, it will not support those browser versions. The code should still work on Moodle, but some of your build tooling may complain about unbuilt changes if you actively run grunt
or similar tooling against multiple Moodle versions. Likewise, if you build against Moodle 3.11 or earlier and check this code in, then this will cause errors when running grunt
on the master/4.0 branches.
If this matters to you then you will need to fork your plugin for Moodle 4.0. Some of you may already be thinking about doing this for Moodle 4.0 given the breadth of other changes that you have to make for your plugin anyway.
If your organisation still cares about supporting IE11, then there are ways that you can re-insert the relevant polyfills as part of your deployment process (essentially update the .grunt/tasks/javascript.js
file and update the IE support line, then run grunt amd
).
If you have any feedback on this change, please let me know. This change is tracked in MDL-73915.
Best wishes,
Andrew Lyons
Principle Developer
Moodle LMS Team