Skip to content

Commit a9a3361

Browse files
committed
Change stats wording when all exports are used
1 parent 1d35f36 commit a9a3361

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

lib/Stats.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -922,19 +922,30 @@ class Stats {
922922
if (module.usedExports !== undefined) {
923923
if (module.usedExports !== true) {
924924
colors.normal(prefix);
925-
if (module.usedExports === null)
925+
if (module.usedExports === null) {
926926
colors.cyan("[used exports unknown]");
927-
else if (module.usedExports === false)
927+
} else if (module.usedExports === false) {
928928
colors.cyan("[no exports used]");
929-
else if (
929+
} else if (
930930
Array.isArray(module.usedExports) &&
931931
module.usedExports.length === 0
932-
)
932+
) {
933933
colors.cyan("[no exports used]");
934-
else if (Array.isArray(module.usedExports))
935-
colors.cyan(
936-
`[only some exports used: ${module.usedExports.join(", ")}]`
937-
);
934+
} else if (Array.isArray(module.usedExports)) {
935+
const providedExportsCount = Array.isArray(module.providedExports)
936+
? module.providedExports.length
937+
: null;
938+
if (
939+
providedExportsCount !== null &&
940+
providedExportsCount === module.usedExports.length
941+
) {
942+
colors.cyan("[all exports used]");
943+
} else {
944+
colors.cyan(
945+
`[only some exports used: ${module.usedExports.join(", ")}]`
946+
);
947+
}
948+
}
938949
newline();
939950
}
940951
}

test/statsCases/tree-shaking/expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ bundle.js 7.27 KiB 0 [emitted] main
66
Entrypoint main = bundle.js
77
[0] ./a.js 13 bytes {0} [built]
88
[exports: a]
9-
[only some exports used: a]
9+
[all exports used]
1010
[1] ./b.js 13 bytes {0} [built]
1111
[exports: b]
1212
[no exports used]

0 commit comments

Comments
 (0)