This plugin uses Moodle's AMD (Asynchronous Module Definition) system for JavaScript. Source files live in amd/src/ and must be minified to amd/build/ before deployment.
Important: Both source and built files must be committed to git. Moodle loads the minified files directly from amd/build/ - there is no build step during deployment.
amd/
├── src/ # Source files (edit these)
│ ├── initmathjax.js
│ ├── initmathjax-backward.js
│ └── updatemastery.js
└── build/ # Minified files + source maps (commit these)
├── *.min.js
└── *.min.js.map
After modifying any file in amd/src/, rebuild the minified version:
npx terser amd/src/FILENAME.js -o amd/build/FILENAME.min.js -c -m --source-map "url='FILENAME.min.js.map'"Example for updatemastery.js:
npx terser amd/src/updatemastery.js -o amd/build/updatemastery.min.js -c -m --source-map "url='updatemastery.min.js.map'"All JavaScript files must use Moodle's AMD define() format:
define(['dependency1', 'dependency2'], function(dep1, dep2) {
// Module code here
return {
init: function() {
// Initialization code
}
};
});After making functional changes, bump the version in version.php:
$plugin->version = YYYYMMDDXX; // Increment the last two digits- Source file updated in
amd/src/ - Minified file regenerated in
amd/build/ - Source map regenerated in
amd/build/ - All built files staged and committed
-
version.phpbumped (if functional change)