Skip to content

Commit 0ff635c

Browse files
perf(css): build large CSS data tables lazily (#22385)
* perf(css): build large CSS data tables lazily Emit the 15 largest tables in lib/css/data.js as memoized getters so a build parsing CSS never compiles or allocates the ones it doesn't read (data.js load: 1212 KiB -> 770 KiB retained heap). Claude-Session: https://claude.ai/code/session_01XkNSr22NpCKQWxEf9aNoS3 * build: update mdn-data to 2.37.1 Regenerate lib/css/data.js: adds the window-drag property. Claude-Session: https://claude.ai/code/session_01XkNSr22NpCKQWxEf9aNoS3 * build: update @mdn/browser-compat-data to 8.1.4 Regenerate lib/css/data.js with the newer browser support data. Claude-Session: https://claude.ai/code/session_01XkNSr22NpCKQWxEf9aNoS3 * perf(css): type the shorthand initial keywords getter Inference gives up on the nested Map literal inside memoize, leaving the getter untyped; state its type in the generator. Claude-Session: https://claude.ai/code/session_01XkNSr22NpCKQWxEf9aNoS3
1 parent 8e3a04d commit 0ff635c

11 files changed

Lines changed: 5381 additions & 5197 deletions

‎.changeset/040-css-html-syntax-performance.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-
Reduce HTML syntax processing time and memory; load none of it without HTML.
5+
Reduce CSS and HTML syntax time and memory; load only the parts a build uses.

‎lib/css/CssParser.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ const {
2424
parseCommentOptionsInRange
2525
} = require("../util/magicComment");
2626
const memoize = require("../util/memoize");
27-
const { CSS_MODULES_KEYWORDS, CSS_MODULES_KEYWORD_OPTIONS } = require("./data");
27+
const {
28+
CSS_MODULES_KEYWORD_OPTIONS,
29+
getCssModulesKeywords
30+
} = require("./data");
2831
const { SourceProcessor } = require("./syntax");
2932
const {
3033
A,
@@ -416,7 +419,7 @@ const buildKnownProperties = (options = {}) => {
416419
knownProperties.set(
417420
property,
418421
/** @type {Map<string, number>} */
419-
(CSS_MODULES_KEYWORDS.get(property))
422+
(getCssModulesKeywords().get(property))
420423
);
421424
}
422425
}
@@ -2272,7 +2275,7 @@ class CssParser extends Parser {
22722275
if (isDashedIdentifier(name)) return;
22732276
const reserved =
22742277
/** @type {Map<string, number>} */
2275-
(CSS_MODULES_KEYWORDS.get(reservedFrom));
2278+
(getCssModulesKeywords().get(reservedFrom));
22762279
if (reserved.has(toLowerCaseIfNeeded(name))) return;
22772280
const start = A.start(node);
22782281
const end = A.end(node);

0 commit comments

Comments
 (0)