Compile only the sources a dev request needs
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend, build-system
Research direction
Start by measuring eager startup and single-route compilation, then trace compile_dependencies() and Compiler.compile_with_deps() to build the route dependency graph. Add dev-mode first-request compilation with source fingerprints and reverse dependency invalidation; keep / prewarmed. Use temporary-project tests to verify route-specific compilation, warm requests, and shared-component invalidation, and add separate cold and warm route budgets under tests/perf/.
Written by the indexing model from the issue text.
Description
Problem
nx dev scans src and compiles every discovered file at startup. With many routes this puts work into startup and fills the VFS with routes nobody opened. The request path is already cached, but the trade is fixed: everything is compiled before the first request.
The proposal is to compile only what a request needs, with a cache and incremental invalidation, while keeping the request path free of parsing.
Change to make
- Measure the current eager startup and the cost of compiling one route before changing the behaviour.
- In dev, build a route to sources graph from
.nexyimports and the layout chain, reusingcompile_dependencies()andCompiler.compile_with_deps(). - On the first request to a route, compile only the missing or changed sources of that route into the VFS. Keep Python modules in
sys.modulesand Jinja templates inEnvironment.cache. - Keep a per-source fingerprint cache. An unchanged source is not read, parsed or generated at request time.
- Keep a reverse dependency graph. When one source changes, invalidate only the routes that depend on it and compile the changed part on the next request to one of those routes.
- Keep
/prewarmed at startup so the first page budget stays unchanged. Other routes are compiled on first use.
Out of scope
The production build, which stays eager and keeps writing generated files to disk. Framework routes, MDX and the Vite pipeline also stay as they are.
Checks
A new budget in tests/perf/ measures a cold route and a warm route separately. Unit tests with a temporary project assert that /about compiles only its imports and layout, that a second request to the same route compiles nothing, and that editing a shared component invalidates only the routes that use it. The startup, first page, reload and request budgets do not regress. Every added branch is covered by a test.
Relation
Follow-up to #711 and #710. The VFS and the source mapping are already delivered; this issue changes when compilation is triggered.
- Dominant language
- Python
- Stars
- 11
- Forks
- 6
- Avg merge
- 2h 14m
- Merged PRs (30d)
- 265
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from NexyPy/nexy
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area:cli difficulty:intermediate enhancement
Difficulty 2/5 Half a day Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
area:cli area:docs question
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area:docs difficulty:beginner good first issue priority:3
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
area:docs difficulty:beginner good first issue priority:3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
backend: claude chore dependencies
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
briandconnelly/amicus#606 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
semantica-agi/semantica#2320 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
vllm-project/vllm-omni#11465 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
jxxghp/MoviePilot#7699 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
vllm-project/vllm-ascend#24010 ·
Maintainers usually reply within 1 day