es-module-shims 2.0.8 → 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.
@@ -1,96 +1,97 @@
1
- /* ES Module Shims 2.0.8 */
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
- (document.currentScript &&
30
- document.currentScript.src.replace(/\.debug\.js$/ , '-typescript.js')) ||
31
- './es-module-shims-typescript.js';
32
-
33
- const mapOverrides = esmsInitOptions.mapOverrides;
34
-
35
- let nonce = esmsInitOptions.nonce;
36
- if (!nonce && hasDocument) {
37
- const nonceElement = document.querySelector('script[nonce]');
38
- if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
39
- }
40
-
41
- const onerror = globalHook(esmsInitOptions.onerror || noop);
42
-
43
- const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
44
-
45
- function globalHook(name) {
46
- return typeof name === 'string' ? self[name] : name;
47
- }
48
-
49
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
50
- const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
51
- const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');
52
- const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;
53
- const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;
54
- const wasmModulesEnabled = enable.includes('wasm-modules') || enableAll;
55
- const sourcePhaseEnabled = enable.includes('source-phase') || enableAll;
56
- const typescriptEnabled = enable.includes('typescript') || enableAll;
57
-
58
- const onpolyfill =
59
- esmsInitOptions.onpolyfill ?
60
- globalHook(esmsInitOptions.onpolyfill)
61
- : () => {
62
- console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
63
- };
64
-
65
- const baseUrl =
66
- hasDocument ?
67
- document.baseURI
68
- : `${location.protocol}//${location.host}${
69
- location.pathname.includes('/') ?
70
- location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
71
- : location.pathname
72
- }`;
73
-
74
- const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
75
- let { skip } = esmsInitOptions;
76
- if (Array.isArray(skip)) {
77
- const l = skip.map(s => new URL(s, baseUrl).href);
78
- skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
79
- } else if (typeof skip === 'string') {
80
- const r = new RegExp(skip);
81
- skip = s => r.test(s);
82
- } else if (skip instanceof RegExp) {
83
- skip = s => skip.test(s);
84
- }
85
-
86
- const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
87
-
88
- const throwError = err => {
89
- (self.reportError || dispatchError)(err), void onerror(err);
90
- };
91
-
92
- function fromParent(parent) {
93
- return parent ? ` imported from ${parent}` : '';
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;
@@ -1167,6 +1168,10 @@
1167
1168
  return initTs()
1168
1169
  .then(() => {
1169
1170
  const transformed = esmsTsTransform(source, baseUrl);
1171
+ if (transformed !== undefined) {
1172
+ onpolyfill();
1173
+ firstPolyfillLoad = false;
1174
+ }
1170
1175
  return topLevelLoad(
1171
1176
  baseUrl,
1172
1177
  getFetchOpts(script),
@@ -1,96 +1,97 @@
1
- /* ES Module Shims 2.0.8 */
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
- (document.currentScript &&
30
- document.currentScript.src.replace(/\.js$/, '-typescript.js')) ||
31
- './es-module-shims-typescript.js';
32
-
33
- const mapOverrides = esmsInitOptions.mapOverrides;
34
-
35
- let nonce = esmsInitOptions.nonce;
36
- if (!nonce && hasDocument) {
37
- const nonceElement = document.querySelector('script[nonce]');
38
- if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
39
- }
40
-
41
- const onerror = globalHook(esmsInitOptions.onerror || noop);
42
-
43
- const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
44
-
45
- function globalHook(name) {
46
- return typeof name === 'string' ? self[name] : name;
47
- }
48
-
49
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
50
- const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
51
- const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');
52
- const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;
53
- const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;
54
- const wasmModulesEnabled = enable.includes('wasm-modules') || enableAll;
55
- const sourcePhaseEnabled = enable.includes('source-phase') || enableAll;
56
- const typescriptEnabled = enable.includes('typescript') || enableAll;
57
-
58
- const onpolyfill =
59
- esmsInitOptions.onpolyfill ?
60
- globalHook(esmsInitOptions.onpolyfill)
61
- : () => {
62
- console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
63
- };
64
-
65
- const baseUrl =
66
- hasDocument ?
67
- document.baseURI
68
- : `${location.protocol}//${location.host}${
69
- location.pathname.includes('/') ?
70
- location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
71
- : location.pathname
72
- }`;
73
-
74
- const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
75
- let { skip } = esmsInitOptions;
76
- if (Array.isArray(skip)) {
77
- const l = skip.map(s => new URL(s, baseUrl).href);
78
- skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
79
- } else if (typeof skip === 'string') {
80
- const r = new RegExp(skip);
81
- skip = s => r.test(s);
82
- } else if (skip instanceof RegExp) {
83
- skip = s => skip.test(s);
84
- }
85
-
86
- const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
87
-
88
- const throwError = err => {
89
- (self.reportError || dispatchError)(err), void onerror(err);
90
- };
91
-
92
- function fromParent(parent) {
93
- return parent ? ` imported from ${parent}` : '';
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;
@@ -1147,6 +1148,10 @@
1147
1148
  return initTs()
1148
1149
  .then(() => {
1149
1150
  const transformed = esmsTsTransform(source, baseUrl);
1151
+ if (transformed !== undefined) {
1152
+ onpolyfill();
1153
+ firstPolyfillLoad = false;
1154
+ }
1150
1155
  return topLevelLoad(
1151
1156
  baseUrl,
1152
1157
  getFetchOpts(script),
@@ -1,96 +1,97 @@
1
- /* ES Module Shims Wasm 2.0.8 */
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
- (document.currentScript &&
30
- document.currentScript.src.replace(/\.js$/, '-typescript.js')) ||
31
- './es-module-shims-typescript.js';
32
-
33
- const mapOverrides = esmsInitOptions.mapOverrides;
34
-
35
- let nonce = esmsInitOptions.nonce;
36
- if (!nonce && hasDocument) {
37
- const nonceElement = document.querySelector('script[nonce]');
38
- if (nonceElement) nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
39
- }
40
-
41
- const onerror = globalHook(esmsInitOptions.onerror || noop);
42
-
43
- const { revokeBlobURLs, noLoadEventRetriggers, enforceIntegrity } = esmsInitOptions;
44
-
45
- function globalHook(name) {
46
- return typeof name === 'string' ? self[name] : name;
47
- }
48
-
49
- const enable = Array.isArray(esmsInitOptions.polyfillEnable) ? esmsInitOptions.polyfillEnable : [];
50
- const enableAll = esmsInitOptions.polyfillEnable === 'all' || enable.includes('all');
51
- const enableLatest = esmsInitOptions.polyfillEnable === 'latest' || enable.includes('latest');
52
- const cssModulesEnabled = enable.includes('css-modules') || enableAll || enableLatest;
53
- const jsonModulesEnabled = enable.includes('json-modules') || enableAll || enableLatest;
54
- const wasmModulesEnabled = enable.includes('wasm-modules') || enableAll;
55
- const sourcePhaseEnabled = enable.includes('source-phase') || enableAll;
56
- const typescriptEnabled = enable.includes('typescript') || enableAll;
57
-
58
- const onpolyfill =
59
- esmsInitOptions.onpolyfill ?
60
- globalHook(esmsInitOptions.onpolyfill)
61
- : () => {
62
- console.log(`%c^^ Module error above is polyfilled and can be ignored ^^`, 'font-weight:900;color:#391');
63
- };
64
-
65
- const baseUrl =
66
- hasDocument ?
67
- document.baseURI
68
- : `${location.protocol}//${location.host}${
69
- location.pathname.includes('/') ?
70
- location.pathname.slice(0, location.pathname.lastIndexOf('/') + 1)
71
- : location.pathname
72
- }`;
73
-
74
- const createBlob = (source, type = 'text/javascript') => URL.createObjectURL(new Blob([source], { type }));
75
- let { skip } = esmsInitOptions;
76
- if (Array.isArray(skip)) {
77
- const l = skip.map(s => new URL(s, baseUrl).href);
78
- skip = s => l.some(i => (i[i.length - 1] === '/' && s.startsWith(i)) || s === i);
79
- } else if (typeof skip === 'string') {
80
- const r = new RegExp(skip);
81
- skip = s => r.test(s);
82
- } else if (skip instanceof RegExp) {
83
- skip = s => skip.test(s);
84
- }
85
-
86
- const dispatchError = error => self.dispatchEvent(Object.assign(new Event('error'), { error }));
87
-
88
- const throwError = err => {
89
- (self.reportError || dispatchError)(err), void onerror(err);
90
- };
91
-
92
- function fromParent(parent) {
93
- return parent ? ` imported from ${parent}` : '';
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;
@@ -1147,6 +1148,10 @@
1147
1148
  return initTs()
1148
1149
  .then(() => {
1149
1150
  const transformed = esmsTsTransform(source, baseUrl);
1151
+ if (transformed !== undefined) {
1152
+ onpolyfill();
1153
+ firstPolyfillLoad = false;
1154
+ }
1150
1155
  return topLevelLoad(
1151
1156
  baseUrl,
1152
1157
  getFetchOpts(script),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-module-shims",
3
- "version": "2.0.8",
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": "^0.3.0",
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",