perf: import already-loaded modules statically #327
Merged
LadyBluenotes(GitHub profile, opens in a new tab)merged 3 commits into
main fromrefs/pull/327/head·merged by LadyBluenotes(GitHub profile, opens in a new tab) 🎯 Changes#
- Three dynamic imports in
validateand one in the target resolution forstaleasked for modules (yaml,shared/utils,setup/workspace-patterns) that the same files already load through static imports, so they deferred nothing. - Each one made the bundler emit a small facade chunk that Node loaded as an extra file, and
import('yaml')requested the wholeyamlnamespace, which kept everyyamlexport in the bundle. - These modules are now imported statically.
- The built package goes from 744,550 to 728,853 bytes (15,697 fewer; 4,441 fewer gzipped) and from 63 files to 60.
- A cold
intent list --json --no-noticesprocess, the call the session hook makes, is about 1.5 ms faster (57.9 ms to 56.5 ms at the 25th percentile of 30 runs), because it loads fewer files and 15 kB less code. The warm benchmarks are unchanged, exceptvalidate, which is 2.6% faster. - Command output and exit codes do not change.
- Adds a patch changeset.
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr(runpnpm build:allfirst).
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit#
- Improvements
- Reduced the installed package size by 16 kB.
- The
intent validateandintent stalecommands load fewer files, with no change to their behavior.
- 1
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
Note
Currently processing new changes in this PR. This may take a few minutes, please wait...
⚙️ Run configuration
- Configuration used: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e0f99f33-49f1-420e-a577-6cd7591d9b31
📥 Commits
Reviewing files that changed from the base of the PR and between cd5a024a59fbc5c72eace6469b4b0442adc06916 and 36cba8d314945cfe84855c06cb21d1995f01d79f.
📒 Files selected for processing (3)
.changeset/static-imports-already-loaded.mdpackages/intent/src/commands/support.tspackages/intent/src/commands/validate.ts
______________________________________________________ < Plot twist: Your tests were the real bugs all along. > ------------------------------------------------------ \ \ (\__/) (•ㅅ•) / づ✨ Finishing Touches
📝 Generate docstrings
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
- Commit to this branch
- Create a new PR
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment `@coderabbitai help` to get the list of available commands.View your CI Pipeline Execution ↗ for commit 36cba8d314945cfe84855c06cb21d1995f01d79f
Command Status Duration Result nx affected --targets=test:eslint,test:sherif,t...✅ Succeeded 1m 1s View ↗ nx run-many --targets=build✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-04 22:56:20UTCMerging this PR will not alter performance#
✅ 12untouched benchmarks
Comparingperf/static-imports-already-loaded(36cba8d) withmain(cd5a024)
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 36cba8d314945cfe84855c06cb21d1995f01d79f
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR