1.0.0 • Published 3 years ago

modules-map v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

Modules Map

Build Status Coverage Status

A map (extend) to register urls for modules as potential solution to this problem and import via get(module).

// the module owner could register the module
import Modules from 'modules-map';
Modules.set('my-module', 'https://unpkg.com/my-module?module');

// the module consumer can verify it's been registered
import Modules from 'modules-map';
if (Modules.has('my-module'))
  Modules.get('my-module').then(module => {
    module.doStuff();
  });

The module itself registers the global Mpdules map helper so that modules, bundlers, or even runtime scripts, can all benefit from the shared registry.

Note this module requires browsers compatible with ES2015 and dynamic import(...) so it cannot work in IE11 or lower.