Skip to content

Commit

Permalink
Upgrade to esmshims 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Nov 23, 2021
1 parent 3406286 commit 2489bae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/assets/javascripts/es-module-shims.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* ES Module Shims 1.3.0 */
/* ES Module Shims 1.3.2 */
(function () {

const edge = navigator.userAgent.match(/Edge\/\d\d\.\d+$/);
Expand Down Expand Up @@ -211,7 +211,7 @@
if (!nonce) {
const nonceElement = document.querySelector('script[nonce]');
if (nonceElement)
nonce = nonceElement.getAttribute('nonce');
nonce = nonceElement.nonce || nonceElement.getAttribute('nonce');
}

const onerror = globalHook(esmsInitOptions$1.onerror || noop);
Expand Down Expand Up @@ -404,7 +404,7 @@
if (revokeBlobURLs) revokeObjectURLs(Object.keys(seen));
return module;
}
const module = await dynamicImport((shimMode || load.n) ? load.b : load.u, { errUrl: load.u });
const module = await dynamicImport(!shimMode && !load.n && nativelyLoaded ? load.u : load.b, { errUrl: load.u });
// if the top-level load is a shell, run its update function
if (load.s)
(await dynamicImport(load.s)).u$_(module);
Expand Down Expand Up @@ -530,9 +530,9 @@
resolvedSource += source.slice(lastIndex);
}

resolvedSource = resolvedSource.replace(/\/\/# sourceMappingURL=(.*)\s*$/, (match, url) => match.replace(url, () => new URL(url, load.r)));
resolvedSource = resolvedSource.replace(/\n\/\/# sourceMappingURL=([^\n]+)\s*$/, (match, url) => match.replace(url, () => new URL(url, load.r)));
let hasSourceURL = false;
resolvedSource = resolvedSource.replace(/\/\/# sourceURL=(.*)\s*$/, (match, url) => (hasSourceURL = true, match.replace(url, () => new URL(url, load.r))));
resolvedSource = resolvedSource.replace(/\n\/\/# sourceURL=([^\n]+)\s*$/, (match, url) => (hasSourceURL = true, match.replace(url, () => new URL(url, load.r))));
if (!hasSourceURL)
resolvedSource += '\n//# sourceURL=' + load.r;

Expand Down Expand Up @@ -760,11 +760,12 @@
const isDomContentLoadedScript = domContentLoadedCnt > 0;
if (isReadyScript) readyStateCompleteCnt++;
if (isDomContentLoadedScript) domContentLoadedCnt++;
const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, isReadyScript && lastStaticLoadPromise).catch(e => {
const blocks = script.getAttribute('async') === null && isReadyScript;
const loadPromise = topLevelLoad(script.src || `${baseUrl}?${id++}`, getFetchOpts(script), !script.src && script.innerHTML, !shimMode, blocks && lastStaticLoadPromise).catch(e => {
setTimeout(() => { throw e });
onerror(e);
});
if (isReadyScript)
if (blocks)
lastStaticLoadPromise = loadPromise.then(readyStateCompleteCheck);
if (isDomContentLoadedScript)
loadPromise.then(domContentLoadedCheck);
Expand Down
Loading

0 comments on commit 2489bae

Please sign in to comment.