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

Building JS modules with Grunt doesn't work if dirroot contains "/src"

    XMLWordPrintable

Details

    • MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-77995-401
    • MDL-77995-402
    • Hide
      1. Install a site, ensuring it's within a directory whose path includes "src", e.g.

        /home/badgers/src
        

      2. Apply the following patch:

        $ git diff
        diff --git a/reportbuilder/amd/src/audience.js b/reportbuilder/amd/src/audience.js
        index b5392d8c2f4..1fd1d9f6ab9 100644
        --- a/reportbuilder/amd/src/audience.js
        +++ b/reportbuilder/amd/src/audience.js
        @@ -46,7 +46,7 @@ let contextId = 0;
          * @param {String} title
          */
         const addAudienceCard = (className, title) => {
        -    const pendingPromise = new Pending('core_reportbuilder/audience:add');
        +    const pendingPromise = new Pending('core_reportbuilder/audience:addXX');
         
             const audiencesContainer = document.querySelector(reportSelectors.regions.audiencesContainer);
             const audienceCardLength = audiencesContainer.querySelectorAll(reportSelectors.regions.audienceCard).length;
        

      3. Run grunt across entire codebase:

        $ npm install
        $ ./node_modules/.bin/grunt amd
        

      4. Confirm that the build files are in correct location (they show as changed):

        $ git status
        On branch master
        Changes not staged for commit:
          (use "git add <file>..." to update what will be committed)
          (use "git restore <file>..." to discard changes in working directory)
        	modified:   reportbuilder/amd/build/audience.min.js
        	modified:   reportbuilder/amd/build/audience.min.js.map
        	modified:   reportbuilder/amd/src/audience.js
         
        no changes added to commit (use "git add" and/or "git commit -a")
        

      Show
      Install a site, ensuring it's within a directory whose path includes "src", e.g. /home/badgers/src Apply the following patch: $ git diff diff --git a/reportbuilder/amd/src/audience.js b/reportbuilder/amd/src/audience.js index b5392d8c2f4..1fd1d9f6ab9 100644 --- a/reportbuilder/amd/src/audience.js +++ b/reportbuilder/amd/src/audience.js @@ -46,7 +46,7 @@ let contextId = 0; * @param {String} title */ const addAudienceCard = (className, title) => { - const pendingPromise = new Pending('core_reportbuilder/audience:add'); + const pendingPromise = new Pending('core_reportbuilder/audience:addXX'); const audiencesContainer = document.querySelector(reportSelectors.regions.audiencesContainer); const audienceCardLength = audiencesContainer.querySelectorAll(reportSelectors.regions.audienceCard).length; Run grunt across entire codebase: $ npm install $ ./node_modules/.bin/grunt amd Confirm that the build files are in correct location (they show as changed): $ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: reportbuilder/amd/build/audience.min.js modified: reportbuilder/amd/build/audience.min.js.map modified: reportbuilder/amd/src/audience.js   no changes added to commit (use "git add" and/or "git commit -a")
    • 1
    • Team Hedgehog 2023 Sprint 2.1

    Description

      This is an obscure bug, but annoying if you are hit by it

      If you have the word "src" within the path to your Moodle install ($CFG->dirroot, e.g. mine is /opt/moodle/master/src) then building all Javascript module with grunt actually created a "build" directory one level up from dirroot, rather than within it as expected

      $ git diff
      diff --git a/reportbuilder/amd/src/audience.js b/reportbuilder/amd/src/audience.js
      index b5392d8c2f..1fd1d9f6ab 100644
      --- a/reportbuilder/amd/src/audience.js
      +++ b/reportbuilder/amd/src/audience.js
      @@ -46,7 +46,7 @@ let contextId = 0;
        * @param {String} title
        */
       const addAudienceCard = (className, title) => {
      -    const pendingPromise = new Pending('core_reportbuilder/audience:add');
      +    const pendingPromise = new Pending('core_reportbuilder/audience:addXX');
       
           const audiencesContainer = document.querySelector(reportSelectors.regions.audiencesContainer);
           const audienceCardLength = audiencesContainer.querySelectorAll(reportSelectors.regions.audienceCard).length;
      $ ./node_modules/.bin/grunt amd
      Running "ignorefiles" task
       
      Running "eslint:amd" (eslint) task
      Browserslist: caniuse-lite is outdated. Please run:
        npx browserslist@latest --update-db
        Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
       
      Running "rollup:dist" (rollup) task
       
      Done.
      $ git diff
      diff --git a/reportbuilder/amd/src/audience.js b/reportbuilder/amd/src/audience.js
      index b5392d8c2f..1fd1d9f6ab 100644
      --- a/reportbuilder/amd/src/audience.js
      +++ b/reportbuilder/amd/src/audience.js
      @@ -46,7 +46,7 @@ let contextId = 0;
        * @param {String} title
        */
       const addAudienceCard = (className, title) => {
      -    const pendingPromise = new Pending('core_reportbuilder/audience:add');
      +    const pendingPromise = new Pending('core_reportbuilder/audience:addXX');
       
           const audiencesContainer = document.querySelector(reportSelectors.regions.audiencesContainer);
           const audienceCardLength = audiencesContainer.querySelectorAll(reportSelectors.regions.audienceCard).length;
      $ ls -1 ../build
      admin
      availability
      backup
      badges
      blocks
      calendar
      comment
      contentbank
      course
      customfield
      enrol
      filter
      grade
      h5p
      lib
      media
      message
      mod
      payment
      question
      report
      reportbuilder
      search
      theme
      user
      

      Note that running grunt with --root=<relativepath> is not affected, it's only when building everything

      Attachments

        1. (I) Passed -- (311)MDL-77995.png
          69 kB
          Kim Jared Lucas
        2. (I) Passed -- (39)MDL-77995.png
          81 kB
          Kim Jared Lucas
        3. (I) Passed -- (400)MDL-77995.png
          70 kB
          Kim Jared Lucas
        4. (I) Passed -- (401)MDL-77995.png
          78 kB
          Kim Jared Lucas
        5. (I) Passed -- (402)MDL-77995.png
          72 kB
          Kim Jared Lucas
        6. (I) Passed -- (Master)MDL-77995.png
          69 kB
          Kim Jared Lucas

        Issue Links

          Activity

            People

              pholden Paul Holden
              pholden Paul Holden
              Meirza Meirza
              Andrew Lyons Andrew Lyons
              Kim Jared Lucas Kim Jared Lucas
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 5 hours
                  5h

                  Clockify

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