Summary: This guide explains how to structure, load, localize, and build AMD modules correctly in Moodle plugin development.

This is the Moodle-native JavaScript workflow, not a generic frontend pattern. If your plugin uses JavaScript, following the standard AMD structure keeps the code maintainable and deployable.

Use Moodle’s standard AMD layout

Your plugin should contain:

  • amd/src/ for source files
  • amd/build/ for built output

The source file should expose an AMD module using define([...], function (...) { ... }).

Load the module from PHP the Moodle way

Use Moodle’s normal AMD-loading path, for example js_call_amd(), rather than hand-rolling script tags or globals. This keeps dependency loading and caching consistent with the platform.

Inject core services and strings deliberately

The SOP highlights a few common services worth using properly:

  • core/notification
  • core/str
  • core/ajax

Define user-facing strings in the language pack and pass them into JavaScript through the normal Moodle bridge instead of hardcoding them in JS.

Build and commit the generated output

After writing the module, run the normal build process and commit the generated files in amd/build/. That keeps deployments predictable and avoids requiring Node tooling on production servers.


Solin specializes in Moodle plugin development and maintainable custom frontend work. Need help? Contact us.

Solin develops Moodle front-end behaviour with maintainable AMD modules, build tooling, and platform-aware debugging. Need help? Contact us.

Contact us