Skip to content

Commit

Permalink
fix(api/npm/module.js): preload package and ensure package type reque…
Browse files Browse the repository at this point in the history
…sted and loaded match
  • Loading branch information
jwerle committed Apr 23, 2024
1 parent f8db1ea commit 9f5ee9b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/npm/module.js
Expand Up @@ -49,9 +49,12 @@ export async function resolve (specifier, origin = null, options = null) {
const pathname = name.pathname.replace(name.value, '.') || '.'

try {
pkg.load()
// will call `pkg.load()` internally
// can throw `ModuleNotFoundError`
const url = pkg.resolve(pathname, { prefix, type })
const url = pkg.type === type
? pkg.resolve(pathname, { prefix, type })
: pkg.resolve(pathname, { prefix })
return {
package: pkg,
origin: pkg.origin,
Expand Down

0 comments on commit 9f5ee9b

Please sign in to comment.