Skip to content

Conversation

@krassowski
Copy link
Contributor

@krassowski krassowski commented Aug 6, 2025

Fixes #16875

The completion support in JSON editor is preserved:

image

Invalid URLs are validated:

image

Custom jsdelivr style CDNs are supported:

image

Markdown description includes explanation for the supported template values:

image

Things I am not sure about:

  • translations: should I reuse identifiers even if technically these are no longer enum descriptions?
  • exact naming of the values

};
}
if (cdn instanceof Object) {
if (cdn.requiresExactVersion && moduleVersion.startsWith('^')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for this PR, how about we change the format of the package json to just strings, jsdelivr.com and unpkg.com and for these we look at the value and hard code the requireExactVersion and requiresExtension.
If its something else, then we leave it as some default.

However this might not work for mirror jsdeliv sites. then again, we haven't had any requests for mirrored sites, hence I'm inclined to avoid having a more complex package.json and go with just strings.

What to you think?
Does this work for the site you're using?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for taking a look!

Does this work for the site you're using?

No, currently the CDN I target only supports jsdelivr.com format - but I am checking if this can be changed. Out of big CDNs cdnjs.com also requires an exact version and .js suffix (and compared to jsdelivr.com does not have redirects at all), although to support cdnjs the format should also include / instead of @ for version specifier.

Another option would be giving some kind of a format string, like:

https://cdnjs.cloudflare.com/ajax/libs/<library>/<version>/<file>

This would keep the package.json to accept only strings, while allowing for a degree of customization. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thats perfect.
Can we go with a syntax such as ${library} ${version} as opposed to <...>
Asking for that as this is the syntax we use in other parts of VS Code as well.
Then you can mention the supported variables in the configuration UI as below

Again thanks for this great PR.

Screenshot 2025-08-08 at 10 26 46 Screenshot 2025-08-08 at 10 26 51

Copy link
Contributor Author

@krassowski krassowski Aug 8, 2025

Choose a reason for hiding this comment

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

Thank you! Done in 21e9798. For strings I followed the pattern in vscode-pull-request-github and while at it I fixed a typo over there (microsoft/vscode-pull-request-github#7540).

@krassowski krassowski marked this pull request as ready for review August 8, 2025 10:23
@DonJayamanne DonJayamanne self-assigned this Aug 11, 2025
@DonJayamanne
Copy link
Contributor

@krassowski thank you very much, this is great

@vs-code-engineering vs-code-engineering bot added this to the August 2025 milestone Aug 11, 2025
@DonJayamanne DonJayamanne merged commit 64c780f into microsoft:main Aug 11, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to configure custom CDN for widget script sources

3 participants