Releases: GoogleChromeLabs/kv-storage-polyfill
2.0.0
The kv-storage
spec was modified to move the default storage area from a storage
named import to simply the default
import in WICG/kv-storage#71. In kv-storage-polyfill@2.0.0
, this change comes to the polyfill.
Uniform imports for all module types
Since mixed named+default exports present problems for CommonJS and UMD bundles, kv-storage-polyfill
has switched to a pragmatic solution proven in other libraries: the CommonJS and UMD bundles now export the default storage namespace, and StorageArea
can be accessed as a property of it. This allows usage in Node, Webpack and Browserify to follow the ESM naming without requiring additional steps or documentation:
ES Modules Usage:
import storage from 'kv-storage-polyfill'; // default storage namespace
import { StorageArea } from 'kv-storage-polyfill'; // instantiable StorageArea class
import storage, { StorageArea } from 'kv-storage-polyfill'; // you can combine
CommonJS Usage:
const storage = require('kv-storage-polyfill'); // default storage namespace
const storage = require('kv-storage-polyfill').default // also works, just an alias
const { StorageArea } = require('kv-storage-polyfill'); // instantiable StorageArea class
UMD/AMD Usage:
define(['/web/kv-storage-polyfill.umd.js'], function(storage) {
storage === storage.default // default storage area
storage.StorageArea // instantiable StorageArea class
});
Globals Usage:
<script src="/web/kv-storage/polyfill.umd.js"></script>
<script>
const { StorageArea } = kvStoragePolyfill;
const storage = kvStoragePolyfill; // optional `.default` if you want
</script>
The mjs output does not include any compatibility shims or the like, it follows spec.