es-module-shims 2.0.9 → 2.0.10
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 +6 -6
- package/dist/es-module-shims-typescript.js +3 -3
- package/dist/es-module-shims.debug.js +92 -91
- package/dist/es-module-shims.js +92 -91
- package/dist/es-module-shims.wasm.js +92 -91
- package/package.json +2 -2
|
@@ -1,96 +1,97 @@
|
|
|
1
|
-
/* ES Module Shims 2.0.
|
|
1
|
+
/* ES Module Shims 2.0.10 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
|
-
const hasDocument = typeof document !== 'undefined';
|
|
5
|
-
|
|
6
|
-
const noop = () => {};
|
|
7
|
-
|
|
8
|
-
const dynamicImport = (u, errUrl) => import(u);
|
|
9
|
-
|
|
10
|
-
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
11
|
-
|
|
12
|
-
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
13
|
-
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
14
|
-
|
|
15
|
-
// shim mode is determined on initialization, no late shim mode
|
|
16
|
-
const shimMode =
|
|
17
|
-
hasDocument ?
|
|
18
|
-
esmsInitOptions.shimMode ||
|
|
19
|
-
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
20
|
-
.length > 0
|
|
21
|
-
: true;
|
|
22
|
-
|
|
23
|
-
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
24
|
-
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
25
|
-
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
26
|
-
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
27
|
-
const tsTransform =
|
|
28
|
-
esmsInitOptions.tsTransform ||
|
|
29
|
-
(
|
|
30
|
-
document.currentScript
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
4
|
+
const hasDocument = typeof document !== 'undefined';
|
|
5
|
+
|
|
6
|
+
const noop = () => {};
|
|
7
|
+
|
|
8
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
9
|
+
|
|
10
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
11
|
+
|
|
12
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
13
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
14
|
+
|
|
15
|
+
// shim mode is determined on initialization, no late shim mode
|
|
16
|
+
const shimMode =
|
|
17
|
+
hasDocument ?
|
|
18
|
+
esmsInitOptions.shimMode ||
|
|
19
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
20
|
+
.length > 0
|
|
21
|
+
: true;
|
|
22
|
+
|
|
23
|
+
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
24
|
+
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
25
|
+
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
26
|
+
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
27
|
+
const tsTransform =
|
|
28
|
+
esmsInitOptions.tsTransform ||
|
|
29
|
+
(hasDocument &&
|
|
30
|
+
document.currentScript &&
|
|
31
|
+
document.currentScript.src.replace(/\.debug\.js$/ , '-typescript.js')) ||
|
|
32
|
+
'./es-module-shims-typescript.js';
|
|
33
|
+
|
|
34
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
35
|
+
|
|
36
|
+
let nonce = esmsInitOptions.nonce;
|
|
37
|
+
if (!nonce && hasDocument) {
|
|
38
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
39
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const onerror = globalHook(esmsInitOptions.onerror || noop);
|
|
43
|
+
|
|
44
|
+
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
|
45
|
+
|
|
46
|
+
function globalHook(name) {
|
|
47
|
+
return typeof name === 'string' ? self[name] : name;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
51
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
52
|
+
const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');
|
|
53
|
+
const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;
|
|
54
|
+
const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;
|
|
55
|
+
const wasmModulesEnabled = enable.includes('wasm-modules') || enableAll;
|
|
56
|
+
const sourcePhaseEnabled = enable.includes('source-phase') || enableAll;
|
|
57
|
+
const typescriptEnabled = enable.includes('typescript') || enableAll;
|
|
58
|
+
|
|
59
|
+
const onpolyfill =
|
|
60
|
+
esmsInitOptions.onpolyfill ?
|
|
61
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
62
|
+
: () => {
|
|
63
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const baseUrl =
|
|
67
|
+
hasDocument ?
|
|
68
|
+
document.baseURI
|
|
69
|
+
: `${location.protocol}//${location.host}${
|
|
70
|
+
location.pathname.includes('/') ?
|
|
71
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
72
|
+
: location.pathname
|
|
73
|
+
}`;
|
|
74
|
+
|
|
75
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
76
|
+
let { skip } = esmsInitOptions;
|
|
77
|
+
if (Array.isArray(skip)) {
|
|
78
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
79
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
80
|
+
} else if (typeof skip === 'string') {
|
|
81
|
+
const r = new RegExp(skip);
|
|
82
|
+
skip = s => r.test(s);
|
|
83
|
+
} else if (skip instanceof RegExp) {
|
|
84
|
+
skip = s => skip.test(s);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
88
|
+
|
|
89
|
+
const throwError = err => {
|
|
90
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
function fromParent(parent) {
|
|
94
|
+
return parent ? ` imported from ${parent}` : '';
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
const backslashRegEx = /\\/g;
|
package/dist/es-module-shims.js
CHANGED
|
@@ -1,96 +1,97 @@
|
|
|
1
|
-
/* ES Module Shims 2.0.
|
|
1
|
+
/* ES Module Shims 2.0.10 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
|
-
const hasDocument = typeof document !== 'undefined';
|
|
5
|
-
|
|
6
|
-
const noop = () => {};
|
|
7
|
-
|
|
8
|
-
const dynamicImport = (u, errUrl) => import(u);
|
|
9
|
-
|
|
10
|
-
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
11
|
-
|
|
12
|
-
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
13
|
-
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
14
|
-
|
|
15
|
-
// shim mode is determined on initialization, no late shim mode
|
|
16
|
-
const shimMode =
|
|
17
|
-
hasDocument ?
|
|
18
|
-
esmsInitOptions.shimMode ||
|
|
19
|
-
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
20
|
-
.length > 0
|
|
21
|
-
: true;
|
|
22
|
-
|
|
23
|
-
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
24
|
-
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
25
|
-
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
26
|
-
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
27
|
-
const tsTransform =
|
|
28
|
-
esmsInitOptions.tsTransform ||
|
|
29
|
-
(
|
|
30
|
-
document.currentScript
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
4
|
+
const hasDocument = typeof document !== 'undefined';
|
|
5
|
+
|
|
6
|
+
const noop = () => {};
|
|
7
|
+
|
|
8
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
9
|
+
|
|
10
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
11
|
+
|
|
12
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
13
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
14
|
+
|
|
15
|
+
// shim mode is determined on initialization, no late shim mode
|
|
16
|
+
const shimMode =
|
|
17
|
+
hasDocument ?
|
|
18
|
+
esmsInitOptions.shimMode ||
|
|
19
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
20
|
+
.length > 0
|
|
21
|
+
: true;
|
|
22
|
+
|
|
23
|
+
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
24
|
+
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
25
|
+
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
26
|
+
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
27
|
+
const tsTransform =
|
|
28
|
+
esmsInitOptions.tsTransform ||
|
|
29
|
+
(hasDocument &&
|
|
30
|
+
document.currentScript &&
|
|
31
|
+
document.currentScript.src.replace(/\.js$/, '-typescript.js')) ||
|
|
32
|
+
'./es-module-shims-typescript.js';
|
|
33
|
+
|
|
34
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
35
|
+
|
|
36
|
+
let nonce = esmsInitOptions.nonce;
|
|
37
|
+
if (!nonce && hasDocument) {
|
|
38
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
39
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const onerror = globalHook(esmsInitOptions.onerror || noop);
|
|
43
|
+
|
|
44
|
+
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
|
45
|
+
|
|
46
|
+
function globalHook(name) {
|
|
47
|
+
return typeof name === 'string' ? self[name] : name;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
51
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
52
|
+
const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');
|
|
53
|
+
const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;
|
|
54
|
+
const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;
|
|
55
|
+
const wasmModulesEnabled = enable.includes('wasm-modules') || enableAll;
|
|
56
|
+
const sourcePhaseEnabled = enable.includes('source-phase') || enableAll;
|
|
57
|
+
const typescriptEnabled = enable.includes('typescript') || enableAll;
|
|
58
|
+
|
|
59
|
+
const onpolyfill =
|
|
60
|
+
esmsInitOptions.onpolyfill ?
|
|
61
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
62
|
+
: () => {
|
|
63
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const baseUrl =
|
|
67
|
+
hasDocument ?
|
|
68
|
+
document.baseURI
|
|
69
|
+
: `${location.protocol}//${location.host}${
|
|
70
|
+
location.pathname.includes('/') ?
|
|
71
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
72
|
+
: location.pathname
|
|
73
|
+
}`;
|
|
74
|
+
|
|
75
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
76
|
+
let { skip } = esmsInitOptions;
|
|
77
|
+
if (Array.isArray(skip)) {
|
|
78
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
79
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
80
|
+
} else if (typeof skip === 'string') {
|
|
81
|
+
const r = new RegExp(skip);
|
|
82
|
+
skip = s => r.test(s);
|
|
83
|
+
} else if (skip instanceof RegExp) {
|
|
84
|
+
skip = s => skip.test(s);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
88
|
+
|
|
89
|
+
const throwError = err => {
|
|
90
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
function fromParent(parent) {
|
|
94
|
+
return parent ? ` imported from ${parent}` : '';
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
const backslashRegEx = /\\/g;
|
|
@@ -1,96 +1,97 @@
|
|
|
1
|
-
/* ES Module Shims Wasm 2.0.
|
|
1
|
+
/* ES Module Shims Wasm 2.0.10 */
|
|
2
2
|
(function () {
|
|
3
3
|
|
|
4
|
-
const hasDocument = typeof document !== 'undefined';
|
|
5
|
-
|
|
6
|
-
const noop = () => {};
|
|
7
|
-
|
|
8
|
-
const dynamicImport = (u, errUrl) => import(u);
|
|
9
|
-
|
|
10
|
-
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
11
|
-
|
|
12
|
-
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
13
|
-
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
14
|
-
|
|
15
|
-
// shim mode is determined on initialization, no late shim mode
|
|
16
|
-
const shimMode =
|
|
17
|
-
hasDocument ?
|
|
18
|
-
esmsInitOptions.shimMode ||
|
|
19
|
-
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
20
|
-
.length > 0
|
|
21
|
-
: true;
|
|
22
|
-
|
|
23
|
-
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
24
|
-
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
25
|
-
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
26
|
-
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
27
|
-
const tsTransform =
|
|
28
|
-
esmsInitOptions.tsTransform ||
|
|
29
|
-
(
|
|
30
|
-
document.currentScript
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
4
|
+
const hasDocument = typeof document !== 'undefined';
|
|
5
|
+
|
|
6
|
+
const noop = () => {};
|
|
7
|
+
|
|
8
|
+
const dynamicImport = (u, errUrl) => import(u);
|
|
9
|
+
|
|
10
|
+
const optionsScript = hasDocument ? document.querySelector('script[type=esms-options]') : undefined;
|
|
11
|
+
|
|
12
|
+
const esmsInitOptions = optionsScript ? JSON.parse(optionsScript.innerHTML) : {};
|
|
13
|
+
Object.assign(esmsInitOptions, self.esmsInitOptions || {});
|
|
14
|
+
|
|
15
|
+
// shim mode is determined on initialization, no late shim mode
|
|
16
|
+
const shimMode =
|
|
17
|
+
hasDocument ?
|
|
18
|
+
esmsInitOptions.shimMode ||
|
|
19
|
+
document.querySelectorAll('script[type=module-shim],script[type=importmap-shim],link[rel=modulepreload-shim]')
|
|
20
|
+
.length > 0
|
|
21
|
+
: true;
|
|
22
|
+
|
|
23
|
+
const importHook = globalHook(shimMode && esmsInitOptions.onimport);
|
|
24
|
+
const resolveHook = globalHook(shimMode && esmsInitOptions.resolve);
|
|
25
|
+
let fetchHook = esmsInitOptions.fetch ? globalHook(esmsInitOptions.fetch) : fetch;
|
|
26
|
+
const metaHook = esmsInitOptions.meta ? globalHook(shimMode && esmsInitOptions.meta) : noop;
|
|
27
|
+
const tsTransform =
|
|
28
|
+
esmsInitOptions.tsTransform ||
|
|
29
|
+
(hasDocument &&
|
|
30
|
+
document.currentScript &&
|
|
31
|
+
document.currentScript.src.replace(/\.js$/, '-typescript.js')) ||
|
|
32
|
+
'./es-module-shims-typescript.js';
|
|
33
|
+
|
|
34
|
+
const mapOverrides = esmsInitOptions.mapOverrides;
|
|
35
|
+
|
|
36
|
+
let nonce = esmsInitOptions.nonce;
|
|
37
|
+
if (!nonce && hasDocument) {
|
|
38
|
+
const nonceElement = document.querySelector('script[nonce]');
|
|
39
|
+
if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const onerror = globalHook(esmsInitOptions.onerror || noop);
|
|
43
|
+
|
|
44
|
+
const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
|
|
45
|
+
|
|
46
|
+
function globalHook(name) {
|
|
47
|
+
return typeof name === 'string' ? self[name] : name;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
|
|
51
|
+
const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
|
|
52
|
+
const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');
|
|
53
|
+
const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;
|
|
54
|
+
const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;
|
|
55
|
+
const wasmModulesEnabled = enable.includes('wasm-modules') || enableAll;
|
|
56
|
+
const sourcePhaseEnabled = enable.includes('source-phase') || enableAll;
|
|
57
|
+
const typescriptEnabled = enable.includes('typescript') || enableAll;
|
|
58
|
+
|
|
59
|
+
const onpolyfill =
|
|
60
|
+
esmsInitOptions.onpolyfill ?
|
|
61
|
+
globalHook(esmsInitOptions.onpolyfill)
|
|
62
|
+
: () => {
|
|
63
|
+
console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const baseUrl =
|
|
67
|
+
hasDocument ?
|
|
68
|
+
document.baseURI
|
|
69
|
+
: `${location.protocol}//${location.host}${
|
|
70
|
+
location.pathname.includes('/') ?
|
|
71
|
+
location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
|
|
72
|
+
: location.pathname
|
|
73
|
+
}`;
|
|
74
|
+
|
|
75
|
+
const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
|
|
76
|
+
let { skip } = esmsInitOptions;
|
|
77
|
+
if (Array.isArray(skip)) {
|
|
78
|
+
const l = skip.map(s => new URL(s, baseUrl).href);
|
|
79
|
+
skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
|
|
80
|
+
} else if (typeof skip === 'string') {
|
|
81
|
+
const r = new RegExp(skip);
|
|
82
|
+
skip = s => r.test(s);
|
|
83
|
+
} else if (skip instanceof RegExp) {
|
|
84
|
+
skip = s => skip.test(s);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
|
|
88
|
+
|
|
89
|
+
const throwError = err => {
|
|
90
|
+
(self.reportError || dispatchError)(err), void onerror(err);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
function fromParent(parent) {
|
|
94
|
+
return parent ? ` imported from ${parent}` : '';
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
const backslashRegEx = /\\/g;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-module-shims",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"description": "Shims for the latest ES module features",
|
|
5
5
|
"main": "dist/es-module-shims.js",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@rollup/plugin-replace": "^2.4.2",
|
|
34
|
-
"amaro": "
|
|
34
|
+
"amaro": "0.3.2",
|
|
35
35
|
"es-module-lexer": "1.6.0",
|
|
36
36
|
"kleur": "^4.1.4",
|
|
37
37
|
"mime-types": "^2.1.33",
|