Repository navigation
perf(cli): doctor's theme checks and the codemods' parser load postcss only when they read a stylesheet - #11925
Conversation
…s only when they read a stylesheet
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet.
Moving doctor's theme checks and the codemods' parser to the shared postcss() getter leaves the CLI's output and API unchanged, and importing @astryxdesign/cli/api no longer loads postcss. The updated guard in test/lazy-dependencies.test.mjs fails if either module imports postcss at its top again. Nothing blocks; one optional fix:
- The getter's doc comment (
packages/cli/foundation/runtime/lazy-dependencies.mjs:74-76) lists the font stylesheet reader among the modules on the API's import path, but importing the API does not load it; the theme commands do.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Changeset: doctor starts about 6 to 10 ms sooner. Verified in mechanism: doctor in the sandbox app loads 28 fewer postcss files, and postcss takes about 15 ms to load here; the exact figure is the author's measurement and was not reproduced.
- Changeset: a first lookup with an integration that imports the API is about 15 ms sooner. Verified in mechanism: contribution validation loads integration codemods, and importing the API no longer loads postcss; the figure was not reproduced.
- Changeset: both modules loaded postcss as they loaded, so every API importer did. Verified: importing the API loads 41 CommonJS files on the base, 28 of them postcss, and none on the head.
- Changeset: they now load postcss only when they read a stylesheet. Verified at
theme-checks.mjs:469,:536andparse.mjs:48. - Changeset and description: output does not change. Verified: doctor's output is identical, and 244 test files pass.
- Description: postcss is 28 CommonJS files. Verified.
- Description: doctor always loaded it. Verified:
doctor.mjsimports the theme checks at load. - Description: both modules use the shared getter, and postcss joins
LAZY_PACKAGES. Verified. - Description: the first test row accepts an ES module entry that hands on the CommonJS exports. Verified at
lazy-dependencies.test.mjs:84-90. - Description: importing the API loads no CommonJS package, so one first use proves the scan. Verified at
lazy-dependencies.test.mjs:154-171. - Description: the API row covers the dropped theme-build row. Verified: importing the API loads the theme build module.
- Description: five other modules still import postcss at their top and are off the API's import path. Verified.
- Description: the timing table. The author's measurement; not reproduced here.
- Description: the guard fails when the theme checks import postcss at their top again. Verified by mutation, and also for the codemods' parser.
- Description: the listed test folders pass. Verified: 244 files, with the lazy-dependency test itself.
- Description: no output, flag or JSON shape changes. Verified.
- File
.changeset/postcss-api-on-first-use.md: clear. - File
packages/cli/api/doctor/theme-checks.mjs: clear. - File
packages/cli/assets/codemods/parse.mjs: clear. - File
packages/cli/foundation/runtime/lazy-dependencies.mjs: non-blocking doc-comment note, lines 74-76. - File
packages/cli/test/lazy-dependencies.test.mjs: clear.
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approved pending CI: CI's heavy jobs have not run on this head yet, because its admission job found no room under the CI ceiling ("CI is full"); re-run the CI workflow so they run.
Doctor's theme checks and the codemods' parser now load postcss through the shared postcss() getter, so importing @astryxdesign/cli/api no longer loads postcss, and the CLI's output and API are unchanged. The reworded doc comment on the getter fixes the earlier note: it no longer places the font stylesheet reader on the API's import path. Nothing blocks.
Claims and files checked
Review mode: incremental; reason: none
- Changed rules (0): none.
- Changeset: doctor starts about 6 to 10 ms sooner. Verified in mechanism: doctor no longer loads postcss at start, and postcss takes about 15 ms to load; the exact figure is the author's measurement and was not reproduced.
- Changeset: a first lookup with an integration that imports the API is about 15 ms sooner. Verified in mechanism: importing the API no longer loads postcss; the figure was not reproduced.
- Changeset: both modules loaded postcss as they loaded, so every API importer did. Verified: importing the API loads 41 CommonJS files on the base, 28 of them postcss, and none on the head.
- Changeset: they now load postcss only when they read a stylesheet. Verified at
theme-checks.mjs:469,:536andparse.mjs:48. - Changeset and description: output does not change. Verified: doctor's output is identical, and 244 test files pass.
- Description: postcss is 28 CommonJS files. Verified.
- Description: doctor always loaded it. Verified:
doctor.mjsimports the theme checks at load. - Description: both modules use the shared getter, and postcss joins
LAZY_PACKAGES. Verified attheme-checks.mjs:12,parse.mjs:15andlazy-dependencies.mjs:93. - Description: the first test row accepts an ES module entry that hands on the CommonJS exports. Verified at
lazy-dependencies.test.mjs:78-91. - Description: importing the API loads no CommonJS package, so one first use proves the scan sees a load. Verified at
lazy-dependencies.test.mjs:140-173. - Description: the API row covers the dropped theme-build row. Verified: importing the API loads the theme build module.
- Description: five other modules still import postcss at their top and are off the API's import path. Verified.
- Description: the timing table and the battery result. The author's measurement; not reproduced.
- Description: every timed run printed the same output as main. The author's measurement; doctor's identical output was checked separately.
- Description: the guard fails when the theme checks import postcss at their top again. Verified by mutation.
- Description: the listed test folders pass. Verified: 244 files, with the lazy-dependency test itself.
- Description: no output, flag or JSON shape changes. Verified.
- File
.changeset/postcss-api-on-first-use.md: clear. - File
packages/cli/api/doctor/theme-checks.mjs: clear. - File
packages/cli/assets/codemods/parse.mjs: clear. - File
packages/cli/foundation/runtime/lazy-dependencies.mjs: clear; the earlier doc-comment note is fixed. - File
packages/cli/test/lazy-dependencies.test.mjs: clear.
Summary
Doctor's theme checks (
api/doctor/theme-checks.mjs) and the codemods' parser (assets/codemods/parse.mjs) imported postcss at their top. The API's index reaches both, so every run that loads the API loaded all of postcss (28 CommonJS files) whether or not it read a stylesheet:doctoralways did, and so does a run whose integration's codemods import the CLI's API, which a project's first lookup loads.postcss()fromfoundation/runtime/lazy-dependencies.mjs, so postcss loads only when a stylesheet is parsed.postcssjoinsLAZY_PACKAGES, sotest/lazy-dependencies.test.mjsnow checks that importing the API loads none of it.requireandimportmust give the same module.postcss().Evidence
Wall time per call, a fresh process each, interleaved, n=11, median paired difference (95% CI), against main with the first postcss change:
doctor(two cases, warm)doctor(two cases, warm)componentcall in a new homedoctorcall in a new homeEvery other case of the 51-case battery is within noise in both projects: weighted −0.3% (one integration) and −0.1% (core only). Identity: every timed run printed the same stdout and stderr, with the same exit code, as main.
Tests
test/lazy-dependencies.test.mjs: importing the API loads noLAZY_PACKAGESmember, postcss now among them. The row fails with postcss imported at the top oftheme-checks.mjsagain.api/upgrade,assets,api/doctor,foundation/doc-compiler(each first-use load site listed) andclients/cli/commandspass: 243 files.Scope
No output, flag or JSON shape changes.