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

Grunt babel should replace names of modules

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.0
    • Fix Version/s: None
    • Component/s: JavaScript
    • Labels:
    • Testing Instructions:
      Hide
      1. Run grunt babel:dist
        1. Confirm that there were no changes in built files

          git status
          

      2. Run grunt watch in a window
      3. Unzip the attached 71882.zip into the lib/amd/src directory
        1. Confirm that the new files were built by grunt watch
        2. Confirm that the output included the following lines:

          Replacing module name 'arl-test1' with core/test1
          Replacing module name 'arl-test2' with core/test2
          

        3. Confirm that the output did not include any other warnings about core/test3 or core/test4*
      4. In your browser open the Browser Developer tools -> Console, and run:

        require(['core/test5'])
        

        1. Confirm that the following output was shown:

          arl-test1 loaded
          arl-test2 loaded
          arl-test4 loaded
          arl-test4 loaded
          

      Show
      Run grunt babel:dist Confirm that there were no changes in built files git status Run grunt watch in a window Unzip the attached 71882.zip into the lib/amd/src directory Confirm that the new files were built by grunt watch Confirm that the output included the following lines : Replacing module name 'arl-test1' with core/test1 Replacing module name 'arl-test2' with core/test2 Confirm that the output did not include any other warnings about core/test3 or core/test4* In your browser open the Browser Developer tools -> Console, and run: require(['core/test5']) Confirm that the following output was shown : arl-test1 loaded arl-test2 loaded arl-test4 loaded arl-test4 loaded
    • Affected Branches:
      MOODLE_400_STABLE
    • Pull 3.10 Branch:
      MDL-71882-310
    • Pull 3.11 Branch:
      MDL-71882-311
    • Pull Master Branch:
      MDL-71882-master

      Description

      If a third-party JS module is included and it already has a named define, then we should replace that name rather than trying to add to it (which we currently do).

      The signature for the define call is:

           define = function (name, deps, callback) {
      

      https://github.com/requirejs/requirejs/blob/master/require.js#L2061

      We can easily replace any provided name with the calculated one. We know it will always be a String if provided (it's optional). We already perform AST translations so this should be trivial.

        Attachments

          Activity

            People

            Assignee:
            dobedobedoh Andrew Lyons
            Reporter:
            dobedobedoh Andrew Lyons
            Peer reviewer:
            Simey Lameze Simey Lameze
            Participants:
            Component watchers:
            Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:

                Time Tracking

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