cdn-resolve
Version:
Resolves import paths to their CDN equivalents
28 lines (26 loc) • 762 B
JavaScript
const require_parse = require('./parse-CDYH5MAa.cjs');
//#region src/unpkg.ts
/**
* Builds the URL for the specified module on unpkg.com.
* @param {string} module - The name of the module.
* @param {UnpkgOptions} options - configuration options.
* @returns {URL} The URL for the module on unpkg.com.
*/
function buildUnpkgUrl(module$1, options) {
try {
const pkg = require_parse.parsePackage(module$1);
const url = new URL(pkg.full, "https://unpkg.com/");
if (options?.meta) url.searchParams.set("meta", "true");
if (options?.module) url.searchParams.set("module", "true");
return url;
} catch {
return;
}
}
//#endregion
Object.defineProperty(exports, 'buildUnpkgUrl', {
enumerable: true,
get: function () {
return buildUnpkgUrl;
}
});