moodlehq/moodle-local_importmapshim
Composer 安装命令:
composer require 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.
README 文档
README
A Moodle local plugin that injects the es-module-shims polyfill into every page, enabling import map support for browsers that do not natively support the feature.
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 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.
| Layer | Who provides it |
|---|---|
| Import map definition + React modules | Moodle core |
| Native import map support | Modern browsers |
| Import map support on older browsers | This plugin (via es-module-shims) |
Requirements
- Moodle 5.2 or later
- PHP 8.1 or later
Installation
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 > Notifications to complete the installation.
Manual
- Download the plugin archive.
- Extract it so the plugin folder is at
<moodleroot>/public/local/importmapshim/. - Log in as an administrator and visit Site administration > Notifications.
How it works
The plugin hooks into Moodle's before_standard_top_of_body_html_generation hook (priority 1000) to inject a <script> 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:
| Mode | Behaviour |
|---|---|
Development ($CFG->cachejs = false) |
Short-lived headers, no ETag, 2-second expiry |
| Production | Cache-Control: public, max-age=31536000, immutable with ETag and 304 support |
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 <version>
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
This plugin is licensed under the GNU General Public License v3 or later.
moodlehq/moodle-local_importmapshim 适用场景与选型建议
moodlehq/moodle-local_importmapshim 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「moodle」 「polyfill」 「Importmap」 「esm」 「local-plugin」 「es-module-shims」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 moodlehq/moodle-local_importmapshim 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 moodlehq/moodle-local_importmapshim 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 moodlehq/moodle-local_importmapshim 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A polyfill for pthreads
Pumukit Lms Bundle.
Compatibility layer for emulating enumerations in PHP < 8.1 and native enumerations in PHP >= 8.1
PHP polyfill for the Apache Functions. The aim is to provides functions as the PHP way in order to get them available even if PHP is not running as an Apache module.
Behat extension that reports with the JUnit format and is compatible with Moodle reruns.
Polyfill for mb_ereg(), mb_eregi(), mb_ereg_match(), and mb_ereg_replace*() functions; primary use case is for mbstring on Windows 7.4+
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 39
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2026-03-24