Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

custom-libraries

WebReflection3ISC0.1.0

A customElements like registry for user-land libraries

customElements, registry, user, libraries

readme

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'});
});