Skip to content

Commit 0352894

Browse files
committed
update
1 parent 6ca9c84 commit 0352894

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

.changeset/unused-css-export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"webpack": patch
33
---
44

5-
Avoid generating JavaScript modules for CSS exports that are not used, reducing unnecessary output and bundle size.
5+
Avoid generating JavaScript modules for CSS exports that are not used, reducing unnecessary output and bundle size.

lib/css/CssGenerator.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ class CssGenerator extends Generator {
363363

364364
if (generateContext.concatenationScope) {
365365
const source = new ConcatSource();
366+
/** @type {Set<string>} */
366367
const usedIdentifiers = new Set();
367368
const { RESERVED_IDENTIFIER } = getPropertyName();
368369

@@ -414,6 +415,7 @@ class CssGenerator extends Generator {
414415
);
415416
}
416417

418+
/** @type {string[]} */
417419
const exports = [];
418420

419421
for (const [name, v] of cssData.exports) {
@@ -500,7 +502,7 @@ class CssGenerator extends Generator {
500502
}
501503
}
502504
}
503-
if (this._exportsOnly) {
505+
if (this._generatesJsOnly(module)) {
504506
if (sourceTypes.has(JAVASCRIPT_TYPE) || isEntryModule) {
505507
return JAVASCRIPT_TYPES;
506508
}

0 commit comments

Comments
 (0)