diff --git a/scripts/lib/dictionaryInfo.mjs b/scripts/lib/dictionaryInfo.mjs index f916c9b540f..e16aeb2a60a 100644 --- a/scripts/lib/dictionaryInfo.mjs +++ b/scripts/lib/dictionaryInfo.mjs @@ -37,6 +37,7 @@ const rootUrl = new URL('../../', import.meta.url); * Dictionary Package information. * @typedef {object} DictionaryPackageInfo * @property {string} name The name of the dictionary. + * @property {string} version The version of the package. * @property {string} packageName The name of the package. * @property {string} dir The directory containing the dictionary package. * @property {boolean} cspell The dictionary package is bundled with cspell. @@ -82,6 +83,7 @@ export async function fetchDictionaryInfo(dictURL) { const hasEnabledByDefault = dictionaries.some((d) => d.enabled) || undefined; return { name: cspellExt.name || pkgJson.name, + version: pkgJson.version, dir: path.relative(rootUrl.pathname, dictURL.pathname), packageName: pkgJson.name, description: cspellExt.description || pkgJson.description || '', diff --git a/scripts/lib/gen-dict-static-files.mjs b/scripts/lib/gen-dict-static-files.mjs index 9ef73975c07..fa261a20bc6 100644 --- a/scripts/lib/gen-dict-static-files.mjs +++ b/scripts/lib/gen-dict-static-files.mjs @@ -96,9 +96,10 @@ function toCSpellSettings(pkgInfo, useCdn) { const locales = [...new Set(pkgInfo.dictionaries.flatMap((d) => d.locales || []))].join(', '); if (!pkgInfo.cspell) { - settings['import'] = [ - (useCdn ? pkgNameToCdnUrl(pkgInfo.packageName) : pkgInfo.packageName) + '/cspell-ext.json', - ]; + const importPkg = useCdn + ? new URL('cspell-ext.json', pkgNameToCdnUrl(pkgInfo.packageName, pkgInfo.version)).href + : pkgInfo.packageName + '/cspell-ext.json'; + settings['import'] = [importPkg]; } if (locales) { settings['language'] = locales; @@ -112,10 +113,12 @@ function toCSpellSettings(pkgInfo, useCdn) { /** * * @param {string} pkgName + * @param {string} version * @returns {string} */ -function pkgNameToCdnUrl(pkgName) { - return `https://cdn.jsdelivr.net/npm/${pkgName}`; +function pkgNameToCdnUrl(pkgName, version) { + const v = version.split('.')[0] || '0'; + return `https://cdn.jsdelivr.net/npm/${pkgName}@${v}/`; } /**