PHPackages                             moodlehq/moodle-local\_importmapshim - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. moodlehq/moodle-local\_importmapshim

ActiveMoodle-local[Utility &amp; Helpers](/categories/utility)

moodlehq/moodle-local\_importmapshim
====================================

A Moodle local plugin that injects the es-module-shims polyfill to enable import map support on browsers that lack native support.

v1.0.0(1mo ago)00GPL-3.0-or-laterPHPPHP &gt;=8.1

Since Mar 24Pushed 1mo agoCompare

[ Source](https://github.com/moodlehq/moodlehq-local_importmapshim)[ Packagist](https://packagist.org/packages/moodlehq/moodle-local_importmapshim)[ RSS](/packages/moodlehq-moodle-local-importmapshim/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Import Map Shim (`local_importmapshim`)
=======================================

[](#import-map-shim-local_importmapshim)

A Moodle local plugin that injects the [es-module-shims](https://github.com/guybedford/es-module-shims) polyfill into every page, enabling import map support for browsers that do not natively support the feature.

Why this plugin exists
----------------------

[](#why-this-plugin-exists)

Moodle 5.2+ adopted **ES module import maps** as the foundation for its React-based UI. An import map is a JSON block in the HTML page that tells the browser how to resolve bare module specifiers like:

```
import React from 'react'; // browser needs to know where 'react' actually lives
```

Moodle core added the import map mechanism but did not ship a polyfill for browsers that lack native support. Older browsers — and some versions of Firefox until recently — do not support import maps natively, causing the entire React-based UI to silently break for those users.

This plugin injects [es-module-shims](https://github.com/guybedford/es-module-shims) into every Moodle page **before** any import map or ES module is parsed. The shim works transparently: on browsers that already support import maps natively it steps aside and does nothing; on older browsers it intercepts module loading and emulates the feature.

LayerWho provides itImport map definition + React modulesMoodle coreNative import map supportModern browsersImport map support on older browsersThis plugin (via es-module-shims)Requirements
------------

[](#requirements)

- Moodle 5.2 or later
- PHP 8.1 or later

Installation
------------

[](#installation)

### Using Git

[](#using-git)

From your Moodle root directory, clone the plugin into the `public/local/` subdirectory:

```
cd /path/to/moodle
git clone https://github.com/moodlehq/moodle-local_importmapshim public/local/importmapshim
```

Then visit **Site administration &gt; Notifications** to complete the installation.

### Manual

[](#manual)

1. Download the plugin archive.
2. Extract it so the plugin folder is at `/public/local/importmapshim/`.
3. Log in as an administrator and visit **Site administration &gt; Notifications**.

How it works
------------

[](#how-it-works)

The plugin hooks into Moodle's `before_standard_top_of_body_html_generation` hook (priority 1000) to inject a `` tag that loads the `es-module-shims` polyfill early in the page lifecycle — before any import map or ES module scripts are evaluated.

The polyfill is served by a dedicated PSR-7 route controller (`/shims/{revision}`) that applies appropriate HTTP cache headers:

ModeBehaviourDevelopment (`$CFG->cachejs = false`)Short-lived headers, no ETag, 2-second expiryProduction`Cache-Control: public, max-age=31536000, immutable` with ETag and 304 supportUpdating the bundled polyfill
-----------------------------

[](#updating-the-bundled-polyfill)

The `es-module-shims` library can be updated by running the helper script:

```
node local/importmapshim/scripts/update-esm-shims.mjs
```

For example:

```
node local/importmapshim/scripts/update-esm-shims.mjs 2.7.0
```

This downloads the specified release, updates `js/es-module-shims.js`, and updates the version metadata in `thirdpartylibs.xml`.

License
-------

[](#license)

This plugin is licensed under the [GNU General Public License v3 or later](LICENSE.md).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af50aff7bc9a1b0863806f0a384ce233451b87a1425b4b4de51aea64810ace59?d=identicon)[andrewnicols](/maintainers/andrewnicols)

![](https://www.gravatar.com/avatar/1357cc7febc619eabeafab294690e7697fe2eac160901b32860e1474e5c0ffcd?d=identicon)[meirza](/maintainers/meirza)

---

Top Contributors

[![meirzamoodle](https://avatars.githubusercontent.com/u/115134930?v=4)](https://github.com/meirzamoodle "meirzamoodle (3 commits)")

---

Tags

polyfillmoodleImportmapesmlocal plugines-module-shims

### Embed Badge

![Health badge](/badges/moodlehq-moodle-local-importmapshim/health.svg)

```
[![Health](https://phpackages.com/badges/moodlehq-moodle-local-importmapshim/health.svg)](https://phpackages.com/packages/moodlehq-moodle-local-importmapshim)
```

###  Alternatives

[symfony/polyfill-mbstring

Symfony polyfill for the Mbstring extension

7.8k1.2B515](/packages/symfony-polyfill-mbstring)[paragonie/random_compat

PHP 5.x polyfill for random\_bytes() and random\_int() from PHP 7

8.2k655.0M405](/packages/paragonie-random-compat)[symfony/polyfill-ctype

Symfony polyfill for ctype functions

4.0k982.0M125](/packages/symfony-polyfill-ctype)[symfony/polyfill-php72

Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions

4.8k674.7M31](/packages/symfony-polyfill-php72)[symfony/polyfill-intl-idn

Symfony polyfill for intl's idn\_to\_ascii and idn\_to\_utf8 functions

3.4k774.6M90](/packages/symfony-polyfill-intl-idn)[symfony/polyfill-intl-normalizer

Symfony polyfill for intl's Normalizer class and related functions

2.1k830.2M36](/packages/symfony-polyfill-intl-normalizer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
