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

Revert NodeJS 18 bump (or significantly alter)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Blocker
    • 3.9.20, 3.11.13, 4.0.7, 4.1.2
    • 3.9.19, 3.11.12, 4.0.6, 4.1.1
    • JavaScript

    Description

      As part of our steps to jump to NodeJS version 18 we include the instruction to remove the npm-shrinkwrap.json and node_modules files, and then to completely regenerate the shrinkwrap from scratch.

      This leads to grandchild dependencies being bumped to their latest version, instead of the version that was available at the time that their parent dependency was installed.

      In many cases this is not a big problem, but unfortunately some of the grandchild dependency changes lead to a significant change to the polyfills included in some cases, which seems to break RequireJS. The most problematic one is the regenerator runtime polyfill used to polyfill await/async, generators, and other newer features of the language.

      The problem in particular is the move from having the regeneratorRuntime globally available, but required by each module; to having it inline in each module. Unfortunately this conflicts with our requirejs transform and we end up with a module that looks like:

      // The regeneratorRuntime minified helper goes here.
      define(["depend", "on", "me"],function(Depend,On,Me){
          // Body of your code.
      });
      

      In our case this breaks requireJS in a variety of fun, and exciting, ways, primarily by
      breaking our search for a define( call to insert the module name. This is because the inline regeneratorRuntime has some code which calls define(...) and our module name insertion matches the first match in the file. This is further conflated by the ordering required to make these all work.

      I believe that this problem stems from https://github.com/babel/babel/pull/14538 and I will be raising a PR because that PR does not seem to include any way to disable it or revert to the previous behaviour.

      To actually fix this in our case will not be easy, but will become easier as many of the regenerator features cease to be needed from 4.0 onwards, though some may be required.

      In the interests of safety, I would recommend that we either:

      • revert all of the previous changes introduced by MDL-75012; or
      • revert all changes to the npm-shrinkwrap, and only update individaul packages to get a bare minimum for NodeJS 18 (LTS/Hydrogen).

      I thought I had achieved the latter already, but as discovered in MDL-77527, the removal and regeneration of the shrinkwrap undid my careful avoidance of this.

      Attachments

        Issue Links

          Activity

            People

              dobedobedoh Andrew Lyons
              dobedobedoh Andrew Lyons
              Ilya Tregubov Ilya Tregubov
              Jun Pataleta Jun Pataleta
              CiBoT CiBoT
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 30 minutes
                  1d 30m

                  Clockify

                    Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.