0.1.0 • Published 4 years ago

custom-libraries v0.1.0

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

customLibraries

Build Status Coverage Status WebReflection status

Social Media Photo by Matteo Maretto on Unsplash

A customElements like registry for user-land libraries.

Based on Some Web Components Hints post idea, but without polluting the customElements registry.

Compatible down to IE9 (with setTimeout polyfill) and every other browser, for a total of 272 bytes once minified and gzipped.

import {define, get, whenDefined} from 'custom-libraries';
// const {define, get, whenDefined} = require('custom-libraries');
// <script src="//unpkg.com/custom-libraries">customLibraries</script>

whenDefined('my-lib').then(myLib => {
  // myLib is defined and passed along
  // get('my-lib') === myLib
});

setTimeout(() => {
  define('my-lib', {any: 'value'});
});