MDL-77559 js: Revert "MDL-75012 js: Drop support for modules built pre-babel"

This reverts commit 84c650489a.
This commit is contained in:
Andrew Nicols
2023-03-09 08:20:53 +08:00
parent 103892b3f0
commit dde8111811
2 changed files with 17 additions and 16 deletions
+17 -11
View File
@@ -104,12 +104,13 @@ if ($rev > 0 and $rev < (time() + 60 * 60)) {
$js = rtrim($js);
$js .= "\n";
if (!preg_match('/define\(\s*["\']/', $js)) {
$shortfilename = str_replace($CFG->dirroot, '', $jsfile);
error_log(
"JS file: '{$shortfilename}' cannot be loaded, or does not contain a javascript" .
' module in AMD format. "define()" not found.'
);
if (preg_match('/define\(\s*(\[|function)/', $js)) {
// If the JavaScript module has been defined without specifying a name then we'll
// add the Moodle module name now.
$replace = 'define(\'' . $modulename . '\', ';
$search = 'define(';
// Replace only the first occurrence.
$js = implode($replace, explode($search, $js, 2));
}
$content .= $js;
@@ -156,11 +157,16 @@ if (!empty($jsfiles)) {
$js = rtrim($js);
}
if (!preg_match('/define\(\s*["\']/', $js)) {
error_log(
"JS file: '{$shortfilename}' cannot be loaded, or does not contain a javascript" .
' module in AMD format. "define()" not found.'
);
if (preg_match('/define\(\s*(\[|function)/', $js)) {
// If the JavaScript module has been defined without specifying a name then we'll
// add the Moodle module name now.
$replace = 'define(\'' . $modulename . '\', ';
// Replace only the first occurrence.
$js = implode($replace, explode('define(', $js, 2));
} else if (!preg_match('/define\s*\(/', $js)) {
debugging('JS file: ' . $shortfilename . ' cannot be loaded, or does not contain a javascript' .
' module in AMD format. "define()" not found.', DEBUG_DEVELOPER);
}
js_send_uncached($js, 'requirejs.php');
-5
View File
@@ -75,14 +75,9 @@ information provided here is intended especially for developers.
* The core/modal module and all their versions (SAVE_CANCEL, DELETE_CANCEL...) now has a setButtonDisable to disable or enable
specific modal action buttons. This function allows developers to have modals that could only be submited if the user do some
action in the modal body like ticking a checkbox or selecting an element.
<<<<<<< HEAD
* Course module indentation has been recovered for course format using components via Move right/left feature.
Course formats using components will be allowed to use one level indentation only.
* The method `flexible_table::set_columnsattributes` now can be used with 'class' key to add custom classes to the DOM.
=======
* Support for serving of AMD modules built in really old versions of Moodle (<= 3.8) has been removed.
Please ensure that your AMD modules have been rebuilt with a supported Moodle version.
>>>>>>> 33b1e41f137ebbdf63f771e8424f7dcc81a5cee8
=== 4.1 ===