bare-module-traverse 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -257,8 +257,6 @@ exports.imports = function* (
|
|
|
257
257
|
|
|
258
258
|
if (value.package) {
|
|
259
259
|
next = resolver.next(JSON.parse(yield { module: value.package }))
|
|
260
|
-
} else if (hasResolution(imports, specifier, matchedConditions)) {
|
|
261
|
-
next = resolver.next(false)
|
|
262
260
|
} else {
|
|
263
261
|
const url = value.resolution
|
|
264
262
|
|
|
@@ -268,20 +266,20 @@ exports.imports = function* (
|
|
|
268
266
|
url.protocol === builtinProtocol ||
|
|
269
267
|
url.protocol === linkedProtocol
|
|
270
268
|
) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
269
|
+
addResolution(imports, specifier, matchedConditions, url)
|
|
270
|
+
|
|
271
|
+
resolved = yielded = true
|
|
274
272
|
} else {
|
|
275
273
|
const source = yield { module: url }
|
|
276
274
|
|
|
277
275
|
if (source !== null) {
|
|
278
|
-
|
|
279
|
-
yield {
|
|
280
|
-
children: exports.module(url, source, artifacts, visited, opts)
|
|
281
|
-
}
|
|
276
|
+
addResolution(imports, specifier, matchedConditions, url)
|
|
282
277
|
|
|
283
|
-
|
|
278
|
+
yield {
|
|
279
|
+
children: exports.module(url, source, artifacts, visited, opts)
|
|
284
280
|
}
|
|
281
|
+
|
|
282
|
+
resolved = yielded = true
|
|
285
283
|
}
|
|
286
284
|
}
|
|
287
285
|
|
|
@@ -497,22 +495,6 @@ function removeURL(array, url) {
|
|
|
497
495
|
if (array[lo].href === url.href) array.splice(lo, 1)
|
|
498
496
|
}
|
|
499
497
|
|
|
500
|
-
function hasResolution(imports, specifier, conditions) {
|
|
501
|
-
if (specifier in imports === false) return false
|
|
502
|
-
|
|
503
|
-
let current = imports[specifier]
|
|
504
|
-
|
|
505
|
-
for (const key of conditions) {
|
|
506
|
-
if (key in current === false || typeof current[key] !== 'object') {
|
|
507
|
-
return false
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
current = current[key]
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
return true
|
|
514
|
-
}
|
|
515
|
-
|
|
516
498
|
function addResolution(imports, specifier, conditions, url) {
|
|
517
499
|
imports[specifier] = imports[specifier] || {}
|
|
518
500
|
|
|
@@ -532,8 +514,6 @@ function addResolution(imports, specifier, conditions, url) {
|
|
|
532
514
|
|
|
533
515
|
const last = conditions[conditions.length - 1]
|
|
534
516
|
|
|
535
|
-
if (last in current) return false
|
|
536
|
-
|
|
537
517
|
current[last] = url.href
|
|
538
518
|
|
|
539
519
|
if ('default' in current) {
|
|
@@ -543,8 +523,6 @@ function addResolution(imports, specifier, conditions, url) {
|
|
|
543
523
|
|
|
544
524
|
current.default = value
|
|
545
525
|
}
|
|
546
|
-
|
|
547
|
-
return true
|
|
548
526
|
}
|
|
549
527
|
|
|
550
528
|
function compressImportsMap(imports) {
|