|
|
|
@ -137,7 +137,9 @@ export class RemixURLResolver { |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
async handleNpmImport(url: string): Promise<HandlerResponse> { |
|
|
|
|
if (this.getDependencies) { |
|
|
|
|
if (!url) throw new Error('url is empty') |
|
|
|
|
const isVersionned = semverRegex().exec(url.replace(/@/g, '@ ').replace(/\//g, ' /')) |
|
|
|
|
if (this.getDependencies && !isVersionned) { |
|
|
|
|
try { |
|
|
|
|
const { deps, yarnLock, packageLock } = await this.getDependencies() |
|
|
|
|
let matchLength = 0 |
|
|
|
@ -177,7 +179,6 @@ export class RemixURLResolver { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const npm_urls = ["https://cdn.jsdelivr.net/npm/", "https://unpkg.com/"] |
|
|
|
|
process && process.env && process.env['NPM_URL'] && npm_urls.unshift(process.env['NPM_URL']) |
|
|
|
|
let content = null |
|
|
|
@ -253,3 +254,8 @@ export class RemixURLResolver { |
|
|
|
|
return imported |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// see npm semver-regex
|
|
|
|
|
function semverRegex() { |
|
|
|
|
return /(?<=^v?|\sv?)(?:(?:0|[1-9]\d{0,9}?)\.){2}(?:0|[1-9]\d{0,9})(?:-(?:--+)?(?:0|[1-9]\d*|\d*[a-z]+\d*)){0,100}(?=$| |\+|\.)(?:(?<=-\S+)(?:\.(?:--?|[\da-z-]*[a-z-]\d*|0|[1-9]\d*)){1,100}?)?(?!\.)(?:\+(?:[\da-z]\.?-?){1,100}?(?!\w))?(?!\+)/gi; |
|
|
|
|
} |
|
|
|
|