es-module-shims 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -4
- package/dist/es-module-shims.debug.js +362 -338
- package/dist/es-module-shims.js +359 -335
- package/dist/es-module-shims.wasm.js +359 -335
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Because we are still using the native module loader the edge cases work out comp
|
|
|
30
30
|
Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
|
|
31
31
|
|
|
32
32
|
```html
|
|
33
|
-
<script async src="https://ga.jspm.io/npm:es-module-shims@2.
|
|
33
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@2.4.0/dist/es-module-shims.js"></script>
|
|
34
34
|
|
|
35
35
|
<!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
|
|
36
36
|
<script type="importmap">
|
|
@@ -701,6 +701,7 @@ Provide a `esmsInitOptions` on the global scope before `es-module-shims` is load
|
|
|
701
701
|
* [revokeBlobURLs](#revoke-blob-urls)
|
|
702
702
|
* [shimMode](#shim-mode-option)
|
|
703
703
|
* [skip](#skip)
|
|
704
|
+
* [version](#version)
|
|
704
705
|
|
|
705
706
|
```html
|
|
706
707
|
<script>
|
|
@@ -738,7 +739,9 @@ window.esmsInitOptions = {
|
|
|
738
739
|
// Hook import.meta construction
|
|
739
740
|
meta: (meta, url) => void // default is noop
|
|
740
741
|
// Hook top-level imports
|
|
741
|
-
onimport: (url, options, parentUrl) => void // default is noop
|
|
742
|
+
onimport: (url, options, parentUrl, source) => void // default is noop
|
|
743
|
+
// Ensure only the exact provided version of es-module-shims registered
|
|
744
|
+
version: '2.4.0' // default is empty
|
|
742
745
|
}
|
|
743
746
|
</script>
|
|
744
747
|
<script async src="es-module-shims.js"></script>
|
|
@@ -888,6 +891,14 @@ When passing an array, relative URLs or paths ending in `/` can be provided:
|
|
|
888
891
|
<script async src="es-module-shims.js"></script>
|
|
889
892
|
```
|
|
890
893
|
|
|
894
|
+
### Version
|
|
895
|
+
|
|
896
|
+
When there is a risk of multiple versions of ES Module Shims on the same page, deconflicting is managed by logic that will opt-out of initializing ES Module Shims if it has already been initialized. In addition, ES Module Shims itself is frozen and locked from further mutations.
|
|
897
|
+
|
|
898
|
+
To better support cooporative multi-version cases, as of version 2.4.0, we support a `version` option, which when set will skip initialization if the current version of ES Module Shims does not match this exact expected version.
|
|
899
|
+
|
|
900
|
+
This way, any other old versions after version 2.4.0 running on the page can effectively be turned off, ensuring only the defined version of the polyfill initiates the polyfill.
|
|
901
|
+
|
|
891
902
|
### Revoke Blob URLs
|
|
892
903
|
|
|
893
904
|
When polyfilling the missing features `es-module-shims` would create in-memory blobs using `URL.createObjectURL()` for each processed module.
|
|
@@ -998,8 +1009,11 @@ The import hook is supported for both shim and polyfill modes and provides an as
|
|
|
998
1009
|
```js
|
|
999
1010
|
<script>
|
|
1000
1011
|
window.esmsInitOptions = {
|
|
1001
|
-
onimport: function (url, options, parentUrl) {
|
|
1002
|
-
|
|
1012
|
+
onimport: function (url, options, parentUrl, source) {
|
|
1013
|
+
if (source !== undefined)
|
|
1014
|
+
console.log(`Top-level inline script with source: ${source}`);
|
|
1015
|
+
else
|
|
1016
|
+
console.log(`Top-level URL import (static or dynamic) for ${url}`);
|
|
1003
1017
|
}
|
|
1004
1018
|
}
|
|
1005
1019
|
</script>
|