|
|
|
@ -137,8 +137,17 @@ export class RemixURLResolver { |
|
|
|
|
if (this.getDependencies) { |
|
|
|
|
try { |
|
|
|
|
const { deps, yarnLock, packageLock } = await this.getDependencies() |
|
|
|
|
for (const pkg of Object.keys(deps)) { |
|
|
|
|
if (url.startsWith(pkg)) { |
|
|
|
|
let matchLength = 0 |
|
|
|
|
let pkg |
|
|
|
|
Object.keys(deps).map((dep) => { |
|
|
|
|
const reg = new RegExp(dep, 'g') |
|
|
|
|
const match = url.match(reg) |
|
|
|
|
if (match && match.length > 0 && matchLength < match[0].length) { |
|
|
|
|
matchLength = match[0].length |
|
|
|
|
pkg = dep |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if (pkg) { |
|
|
|
|
let version |
|
|
|
|
if (yarnLock) { |
|
|
|
|
// yarn.lock
|
|
|
|
@ -157,8 +166,6 @@ export class RemixURLResolver { |
|
|
|
|
version = deps[pkg] |
|
|
|
|
} |
|
|
|
|
if (version) url = url.replace(pkg, `${pkg}@${version}`) |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
}
|
|
|
|
|
} catch (e) { |
|
|
|
|
console.log(e) |
|
|
|
|