Skip to content

[Blazor] Add version-based cache busting to dotnet.js import statements #63164

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

Open
wants to merge 4 commits into
base: release/8.0
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
6 changes: 5 additions & 1 deletion src/Components/Web.JS/src/Platform/Mono/MonoPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ async function importDotnetJs(startOptions: Partial<WebAssemblyStartOptions>): P
}
}

const absoluteSrc = (new URL(src, document.baseURI)).toString();
const absoluteUrl = new URL(src, document.baseURI);
if (!absoluteUrl.searchParams.has('v')) {
absoluteUrl.searchParams.set('v', '8.0.19');
Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded version '8.0.19' should be extracted to a constant or configuration value to make it easier to maintain and update across releases.

Suggested change
absoluteUrl.searchParams.set('v', '8.0.19');
absoluteUrl.searchParams.set('v', DOTNET_JS_VERSION);

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think dotnet.js changes with the used runtime pack Nuget and with installed version of the wasm workload.
This would need some MSBuild magic, not just a constant

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a one-time fix to help alleviate the problem for the people currently facing it in 8.0. Given how transient the nature of this problem is (you have to get an old version, then a new version) I don't plan on building any more complex machinery for this.

In fact, since this is already fixed in 9.0 for hosted scenarios and 10.0, I don't necessarily believe we need to do anything more, but since the change is simple, I'm willing to consider this for a patch. I wouldn't do a fix any more complex than this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see

Copy link
Member

@maraf maraf Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do it only in case there is no custom loadBootResource? Can adding a query string parameter break something?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't worry about it, it's very unlikely that a query string breaks anything, but I don't mind commanding our silicon-based coworker to make that change.

}
const absoluteSrc = absoluteUrl.toString();
return await import(/* webpackIgnore: true */ absoluteSrc);
}

Expand Down
Loading