Repository navigation
Conversation
An idle-server require-graph analysis showed ~1,985 modules of browser-only libraries loaded at server startup: @elastic/eui (1,125), refractor/prismjs (~300), react-intl, react-use, react-redux, @elastic/apm-rum. A single `from '@elastic/eui'` barrel import loads all 1,125 EUI modules, so every server-reachable chain had to be severed: - kbn-discover-utils: internal constants module no longer round-trips through the package barrel; 13 server/common importers (saved_search, discover, canvas, observability, logs_shared) now use pure subpath modules. - kbn-search-connectors: root barrel no longer re-exports ./components; 22 browser files import components from the subpath instead. - kbn-coloring / kbn-palettes / chart-expressions-common / kbn-visualizations-common: server/common importers switched to pure subpaths; isColorDark inlined (EUI ships no d.ts for deep lib paths); the 18 palette files deep-import eui_palettes with an ambient declaration, and kbn-ui-shared-deps exposes that path so browser bundles keep sharing the vis-color singleton. - kbn-cases-components / kbn-user-profile-components: server importers use pure subpaths; VISUALIZATION_COLORS rebuilt from @elastic/eui-theme-borealis colorVis (verified identical output), likewise in security common/model and the infra/observability_shared color palettes. - observability common barrel no longer re-exports ElapsedTimestampTooltip. - ml: anomaly_utils barrel no longer re-exports useSeverityColor/severity_ramp (15 browser consumers moved to subpaths); aiops_log_rate_analysis moves its useEuiTheme hook out of constants.ts. - kbn-ebt-tools server consumers (core analytics, core root, files, home) use the pure performance_metric_events module (drops react-use). - kibana_utils common barrels no longer re-export the React state-container helpers (public API unchanged). - kbn-streamlang: htmlIdGenerator replaced with an equivalent uuid-based factory; ingest_pipelines server route imports MAX_TREE_LEVEL from the pure constants module. Known remaining (flagged for owners, not changed here): fleet agent_policy_settings.tsx keeps @kbn/i18n-react on the server (render-function descriptions), share/common url_service keeps react-use useMountedState, aiops log_rate_analysis keeps one @reduxjs/toolkit slice. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Oct 27, 2026
Adds @kbn/eslint/no_browser_imports_in_server (typescript-eslint no-restricted-imports under a dedicated id, mirroring security_imports_restriction so local overrides cannot drop it) and enforces it as an error for **/server/** files: value imports of @elastic/eui, react, react-dom, react-intl/use/redux, @reduxjs/toolkit, redux, @emotion/*, refractor, prismjs, @elastic/apm-rum*, and @kbn/i18n-react are banned; type-only imports stay allowed, as do the pure @elastic/eui-theme-* packages. A repo sweep of the 16,936 matching server files found only six existing imports from the banned set, all type-only, so the rule lands with zero violations. This guards the direct-import regression class only; transitive chains through shared packages remain covered by the measurements in this PR. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
sphilipse
force-pushed
the
server-no-eager-eui
branch
from
October 30, 2026 12:36
ce21e9f to
950fedd
Compare
This was referenced Oct 30, 2026
Member
Author
|
Split into smaller, independently mergeable PRs per review feedback:
The union of the eight splits equals this PR's diff (130 files, validated together: full check.js run + runtime require-graph verification). Measurements and chain analysis remain in this PR's description; the end state is enforced by the runtime gate in #302010, which stays unmerged until every part plus the GenAI PR (#300921) and the three flagged residue follow-ups land. |
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.
Summary
An idle-server require-graph analysis showed ~1,985 modules of browser-only libraries loaded at Kibana server startup:
@elastic/eui(1,125 modules), refractor/prismjs (~300), react-intl, react-use, react-redux,@elastic/apm-rum. A singlefrom '@elastic/eui'barrel import loads all 1,125 EUI modules, so every server-reachable chain is severed in this PR (the commit message lists each chain; highlights below):./components; 22 browser files import components from the subpath.isColorDarkinlined (EUI ships no d.ts for deep lib paths); the 18 palette files deep-importeui_paletteswith an ambient declaration, and kbn-ui-shared-deps exposes that path so browser bundles keep sharing the vis-color singleton. Flagging for@elastic/kibana-visualizations: please sanity-check the deep-import + shared-deps approach.VISUALIZATION_COLORSrebuilt from@elastic/eui-theme-borealiscolorVis(verified byte-identical), likewise in securitycommon/modeland the infra/observability_shared color palettes.useEuiThemehook out ofconstants.ts.performance_metric_eventsmodule (drops react-use); kibana_utils common barrels no longer re-export the React state-container helpers (public API unchanged); kbn-streamlang replaceshtmlIdGeneratorwith an equivalent uuid factory.Measured impact (idle server, allocation-tracking preload, GC-forced heap snapshot + full require graph)
On a production source build, this PR combined with the GenAI lazy-loading PR measures −120 MB idle heap (697.4 → 577.4 MB) and −3,893 modules; roughly half of that is attributable to this PR based on the dev split.
After this PR the server's require graph contains 3
@elastic/euimodules (the deep palette path) and zero refractor/prismjs/apm-rum. Known remaining, flagged for owners rather than changed here: fleetagent_policy_settings.tsxkeeps@kbn/i18n-react(render-function descriptions), shareurl_servicekeeps react-useuseMountedState, aiops keeps one@reduxjs/toolkitslice.Testing
node scripts/check.js --scope=local: tsc, eslint, and 16,045 jest tests across 20 configs passnode scripts/build) succeeds with the ui-shared-deps/ambient-d.ts changesRelated: #300785, #300786 (independent; measurements above were taken on top of them).
🤖 Generated with Claude Code
Production measurements (cumulative)
Idle production source builds (
node scripts/build,bin/kibanaagainst a local ES, allocation-tracking preload, 2 min idle, GC-forced heap snapshot + full require graph; same machine and protocol for every row):main(63948de)Single-run samples; heap_used has ±10 MB run noise, snapshot self size is GC-forced and stabler.
Status: on hold pending elastic/eui#10247
The deep-import + ambient-d.ts workaround for the 18 kbn-palettes files exists only because the palette functions aren't individually importable from EUI today. elastic/eui#10247 moves them to
@elastic/eui-theme-common; once that lands and Kibana upgrades EUI, the palette portion of this PR becomes a clean typed import (from '@elastic/eui-theme-common') and the ambient declaration + shared-deps entry for the deep path can be dropped. Holding merge until then.