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

Building JS modules with Grunt places build files in src folder on Windows

    XMLWordPrintable

Details

    Description

      On MDL-77995, the functon 'babelRename' was changed to:

      {{
      const babelRename = function(destPath, srcPath) {
      const path = require('path');
      destPath = srcPath.replace(`amd${path.sep}src`, `amd${path.sep}build`);
      destPath = destPath.replace(/\.js$/, '.min.js');
      return destPath;
      };
      }}

      However, 'grunt' always uses the forward slash and so on Windows that uses a backslash (as would be seen in the path separator variable) then the 'build' files end up in the 'src' folder and not the 'build' folder.

      This can be evidenced by changing the code to:

      {{
      const babelRename = function(destPath, srcPath) {
      const path = require('path');
      console.log(srcPath);
      destPath = srcPath.replace(`amd${path.sep}src`, `amd${path.sep}build`);
      console.log(destPath);
      destPath = destPath.replace(/\.js$/, '.min.js');
      return destPath;
      };
      }}

      then with the Adaptable theme installed (on Windows) - https://moodle.org/plugins/theme_adaptable/401.1.5/29152 - run the command (either in cmd.exe (right in screenshot) or the Node.js Command Prompt(left in screenshot)) in the Moodle root -> 'grunt amd --root=theme\adaptable' and observe what the code sees in its strings and the resulting build files in the src folder:

      The fix / workaround is simply:

      destPath = srcPath.replace(`amd/src`, `amd/build`);

      Attachments

        Issue Links

          Activity

            People

              gb2048 Gareth J Barnard
              gb2048 Gareth J Barnard
              Paul Holden Paul Holden
              Andrew Lyons Andrew Lyons
              Jun Pataleta Jun Pataleta
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                12/Jun/23

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 50 minutes
                  1h 50m