Skip to content

Commit

Permalink
Fix misclassified dual explicit/implicit combo
Browse files Browse the repository at this point in the history
When combining an explicit condition (`import` or `require`),
and then using the `default` condition for the other one,
that wasn’t picked up correctly.
Now it is.

Closes GH-9.
  • Loading branch information
wooorm committed May 27, 2024
1 parent 88bf19b commit e87f4d4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions script/crawl.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,19 @@ function analyzePackument(result) {
}
} else {
let explicit = false
if ('import' in value && value.import) {
const conditionImport = Boolean('import' in value && value.import)
const conditionRequire = Boolean('require' in value && value.require)
const conditionDefault = Boolean('default' in value && value.default)

if (conditionImport || conditionRequire) {
explicit = true
}

if (conditionImport || (conditionRequire && conditionDefault)) {
esm = true
}

if ('require' in value && value.require) {
explicit = true
if (conditionRequire || (conditionImport && conditionDefault)) {
cjs = true
}

Expand Down

0 comments on commit e87f4d4

Please sign in to comment.