Skip to content

ungap/ungap.github.io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ungap

Modern Web development one jump at the time

jumping the gap Photo by Denny Luan on Unsplash

About

The ungap project was born after years of attempts to always fix the same issue, but never in a modular way and, most importantly, never in a single, 100% code covered, organization.

Focused on size, compatibility, and quality

Each module is written in ES5 compatible syntax to avoid both unnecessary transpilers bloat and potentially unexpected behaviors. Each module is also 100% code-covered through tests able to verify the whole API both as native and polyfilled version. The constrains per module are the following:

  • CommonJS, ESM, Worker, and Web compatibility.
  • easy to read and maintain ES5 syntax, keeping the code size in mind.
  • mandatory 100% code coverage through all possible NodeJS hacks to ensure every part of the code that has a meaning works as expected (some meaningless part can be skipped but functionalities must be ensured).
  • every module is stand-alone, allowing incremental patch or polyfilling.
  • modules should be bundlers and transpilers resistant to avoid any possible, production code, surprise [1].

[1] as example: stripped out features detections

Pragmatic is better than (im)perfect

There are parts of the specifications that are very hard, if not impossible, to polyfill. The main purpose of this project is to help developers move forward, and possibly without unnecessary bloat. This basically means that polyfills are written to support 99% of the use cases, without granting 100% spec compliance.

If you need that, which again is basically impossible in most of the cases, feel free to keep using whatever monolithic polyfill or approach you were using before.

How to use a module

Every single module is made available as ESM, through the package.json's module field, CJS via package.json's main field, and browser script polyfill / patch via package.json's unpkg field so that you can use directly the unpkg CDN.

// as ECMAScript module
import WeakSet from '@ungap/weakset';

// as CommonJS module
const WeakSet = require('@ungap/weakset');

// as Browser global patch
<script src="https://unpkg.com/@ungap/weakset"></script>

Essential polyfills

Essentials modules covers most common use cases without going full bloated API. As example, the essential-map exposes only get, set, delete, and has which is most of the time everything one needs, as opposite of going full map. The main benefit of the essential modules is their size, simplicity, or even performance.

Regular polyfills

Polyfilled utilities

Ungap utilities are meant to simplify cross browser development without the bloat of a whole polyfill.

Plugins to remove unnecessary bloat

If you are targeting modern browsers only, you might want to exclude some unnecessary code from various ungapped APIs.

Following a list of plugins which aim is to address those cases:

  • babel-plugin-remove-ungap provides the ability to arbitrarily exclude polyfills through tree-shaking, an awesome tool from coreyfarrell
  • @ungap/degap to make any module either a no-op, just the native version, or the simplified utility (as in element-matches case).

License

Each module is under the npm default ISC license.

How to contribute

You are welcome to join the organization after your first module is published.

In order to do so, please take any already available module as example of how to create and test any code you need.

The main guideline though, can be summarized as such:

  • the entry point is the root ./index.js.
  • the ESM module is generated in ./esm/index.js.
  • the CJS module is generated in ./cjs/index.js.
  • you cannot use any transpiler.
  • you might use some bundler as long as the tested code is the one generated by such bundler.

I have personally no interest in enforcing any specific linting rule or code style, as long as common sense and good practices are part of the code.

If these basic constrains are good enough for you, please do help this project grow, allowing the community to leave all monolithic polyfills part of the past.

If you have further questions, you can DM me @webreflection [1]

[1] my DMs are open


About

The ungap landing page.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published