Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM Preload Fix #7161

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/framework/handlers/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,11 @@ class ScriptHandler extends ResourceHandler {
});

// check if we're loading a module or a classic script
const [basePath, search] = url.load.split('?');
const [basePath] = url.load.split('?');
const isEsmScript = basePath.endsWith('.mjs');

if (isEsmScript) {

// The browser will hold its own cache of the script, so we need to bust it
let path = url.load;
if (path.startsWith(this._app.assets.prefix)) {
path = path.replace(this._app.assets.prefix, '');
}

const hash = this._app.assets.getByUrl(path).file.hash;
const searchParams = new URLSearchParams(search);
searchParams.set('hash', hash);
const urlWithHash = `${basePath}?${searchParams.toString()}`;

this._loadModule(urlWithHash, onScriptLoad);
this._loadModule(basePath, onScriptLoad);
} else {
this._loadScript(url.load, onScriptLoad);
}
Expand Down
Loading