Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-73915

Bump NodeJS version, dependencies, and update JS build process, drop IE support

    XMLWordPrintable

Details

    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE
    • MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE
    • MDL-73915-39-terser
    • MDL-73915-311-terser
    • MDL-73915-master-terser
    • Hide

      Behat will test most of this and general browsing whilst testing other issues should capture any other remaining concerns.

      Confirm that the old version of NodeJS is rejected

      1. Use Node version 14.18.0 (nvm use v14.18.0 or nvm use lts/fermium)
      2. Ensure that dependencies and grunt are installed:

        git checkout .
        npm -g i grunt-cli
        npm ci
        

      3. Try to run grunt

        grunt
        

        1. Confirm that you were given an error message about an incorrect NodeJS version:

          Fatal error: Node version not satisfied. Require >=16.14.0 <17.0.0-0, version installed: 14.19.0
          

      4. Install the correct version of NodeJS:

        nvm install
        

      5. Ensure that dependencies and grunt are installed:

        git checkout .
        npm -g i grunt-cli
        npm ci
        

      6. Try to run grunt

        grunt
        

        1. Confirm that grunt ran
      7. When grunt has finished, confirm that there are no chagnes:

        git status
        

      Show
      Behat will test most of this and general browsing whilst testing other issues should capture any other remaining concerns. Confirm that the old version of NodeJS is rejected Use Node version 14.18.0 ( nvm use v14.18.0 or nvm use lts/fermium ) Ensure that dependencies and grunt are installed: git checkout . npm -g i grunt-cli npm ci Try to run grunt grunt Confirm that you were given an error message about an incorrect NodeJS version: Fatal error: Node version not satisfied. Require >=16.14.0 <17.0.0-0, version installed: 14.19.0 Install the correct version of NodeJS: nvm install Ensure that dependencies and grunt are installed: git checkout . npm -g i grunt-cli npm ci Try to run grunt grunt Confirm that grunt ran When grunt has finished, confirm that there are no chagnes: git status

    Description

      Policy: Keeping us on top of nodejs/npm LTS versions (including jumps to next LTS)

      Since September 2018 (MDL-63346):

      1. This policy will be applied to ALL supported branches, normal and security-only.
      2. This policy won't update any tool per se, unless strictly needed by nodejs/npm own dependencies/changes. It won't include npm audit changes either. Those are handled apart. So, normally, only changes to .nvmrc and package.json will happen. That will be achieved by:
        1. update .nvmrc to the new version.
        2. run nvm install && nvm alias default node && nvm use to install, set it as new default and use it for the next steps.
        3. update package.json and set engines to the new restriction (>= new version and < next major).
      3. When needed to bump components or run some audit, a new issue, similar to this, will be created and these steps performed in order to get a renewed npm-shrinkwrap.json file:
        1. remove node_modules & npm-shrinkwrap.json
        2. npm cache clear --force
        3. npm install
        4. npm shrinkwrap
      4. In any case, simple update or complete components bump, run grunt and verify that all the generated css/js/map stuff remains the same. If there are differences in the generation... it will need to be analysed and decided if:
        1. accepted (so everything, shrinkwrap and generated css/js/map) lands [or]
        2. not accepted (and only change .nvmrc and package.json) instead).
      5. The resulting branches will be sent to github (or similar), making a peer-review request here so both travis and cibot will verify that all them pass ok.
      6. Changes will be normally integrated and the NodeJSVersion template and NodeJSExactVersion templates will be updated with latest information in the Docs.
      7. TODO (MDLSITE-5536): A job @ CI servers will be, daily, using latest lts/current version to detect if there are npm-shrinkwrap.json changes. It will fail when that happens and inform integrators. Jumps to lts/next will be detected manually,.

      I'm raising this issue because of some problems with our current build identified in MDL-71708.

      Essentially, our current minification options include an option called mangle (on by default) which in some situations can cause broken JS to be generated. We don't know if/when this may crop up, and the relevant project seems to be abandoned.

      Unfortunately disabling the mangle option causes minified files to be changed, which is something that we try to avoid because it messes with third-party developers and their build processes.

      Given the combination of these things I think that we need to:

      • update the Grunt JS config to set the mangle option to false
      • update our NodeJS version to the latest LTS (16.14.0)
      • update our package versions

      This has the following effects:

      • updates all built JavaScript (YUI and AMD)
      • replace the current babel-minify plugin with a supported minification system (terser)

      This combination fixes the issue blocking MDL-71708.

      I believe we should apply this to master, and stables so that all versions of Moodle have the same NodeJS version support as per policy.

      For master I think we should consider dropping support for IE and adjusting our browser compatibility list accordingly to:

      • remove IE
      • update the browser usage restriction to cover the top 0.3% instead of 0.25 (this removes support for Android 4.4 released in October 2013)

      This combinations of things will:

      • drop use of many of the legacy polyfills for things like for...of, and async
      • which makes debugging async functions much much easier

      This was agreed in MDLSITE-6109 back in August 2020, and was intended to happen in the Moodle 3.10 release. This was not done at the time (due to time constraints).

      Because of this change there will be build output changes in third-party plugins. We do try to avoid this wherever possible but sometimes it is unavoidable. We technically can get away with not modifying minified files, but the older our babel packages get the harder it becomes to upgrade in the future. We will be supporting Moodle 3.9 until May 2023, and it makes more sense to make this change to Moodle 3.10 so that all versions from 3.9 to 3.11 have the same build process, and Moodle 4.0 has the same process but with IE support dropped.

      Attachments

        1. MDL-73915_step 3.png
          MDL-73915_step 3.png
          314 kB
        2. MDL-73915_step 6.png
          MDL-73915_step 6.png
          331 kB
        3. MDL-73915_step 7.png
          MDL-73915_step 7.png
          110 kB

        Issue Links

          Activity

            People

              dobedobedoh Andrew Lyons
              dobedobedoh Andrew Lyons
              Mathew May Mathew May
              Jun Pataleta Jun Pataleta
              Angelia Dela Cruz Angelia Dela Cruz
              Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
              Votes:
              1 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                14/Mar/22

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 2 days, 3 hours, 45 minutes
                  2d 3h 45m