refactor: make vestigial runner-client/app-log dynamic imports static#1214
Open
thymikee wants to merge 1 commit into
Open
refactor: make vestigial runner-client/app-log dynamic imports static#1214thymikee wants to merge 1 commit into
thymikee wants to merge 1 commit into
Conversation
`pnpm build` emitted INEFFECTIVE_DYNAMIC_IMPORT for `app-log.ts`: it is `await import()`ed in `request-platform-providers.ts` but also statically imported by `session-observability`/`session-teardown`, so the dynamic import splits nothing. Investigating revealed a whole class of these — rolldown only reports a subset at a time. Every flagged module is already eager in the daemon entry chunk (`internal/daemon.js`) via static importers, so the `await import()` calls defer nothing: - `app-log.ts`, `runner-provider.ts` — daemon-only, eager via session/teardown/runner-client. Made static in `request-platform-providers.ts`. - `runner-client.ts` — a hub statically imported by ~20 daemon modules (session lifecycle, screenshot, selectors, record-trace, teardown), so it is baked into the daemon entry. The `await import()`s in dispatch / dispatch- interactions / transport / daemon-runtime / http-server (two of them looping per poll iteration) deferred nothing. Made static. Verified safe: - No import cycle (runner-client's 97-module static closure never reaches dispatch/server), so static imports can't introduce an init-order bug. - Byte-identical eager closures for every entry — CLI stays 487,422 B with runner-client absent; only the daemon entry contains it, as before. (Forcing runner-client into its own chunk was rejected: it pulled the full ~97 KB into the CLI's eager closure by defeating tree-shaking of one small constant.) - Build is now warning-free; typecheck, lint, and dispatch/runner/provider/ server-shutdown tests pass.
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
pnpm buildwarned:Investigation
app-log.tsisawait import()ed inrequest-platform-providers.tsbut alsostatically imported elsewhere, so the dynamic import splits nothing. Digging in,
this is a whole class of vestigial dynamic imports — rolldown only surfaces a
subset at a time, so fixing one reveals the next (
runner-provider, thenrunner-client).Every flagged module is already eager in the daemon entry chunk
(
internal/daemon.js) through static importers, so theawait import()callsdefer nothing:
app-log.tssession-observability/session-teardownrunner-provider.tsrunner-clientrunner-client.tsrunner-client'sawait import()s lived indispatch,dispatch-interactions,transport,daemon-runtime,http-server(two of them re-importing on everypoll-loop iteration).
Why this is safe
runner-client's 97-module static closure never reachesdispatch/server, so static imports can't introduce an init-order/TDZ bug.
487,422 B with
runner-clientabsent; only the daemon entry contains it,exactly as before.
runner-clientinto its own chunk was considered and rejected: itdragged the full ~97 KB into the CLI's eager closure by defeating tree-shaking
of one small constant the CLI references.
Result
no-op dynamic imports are just removed.
pnpm typecheck,oxlint, and dispatch / runner / provider-scope /server-shutdown tests all pass.
Diff: 6 files, +20/−19.