Skip to content

Commit b2e3975

Browse files
[9.4] chore: lazy-load server plugin modules (kibana-security) (#266614) (#266699)
# Backport This will backport the following commits from `main` to `9.4`: - [chore: lazy-load server plugin modules (kibana-security) (#266614)](#266614) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Alejandro Fernández Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2026-04-30T14:28:34Z","message":"chore: lazy-load server plugin modules (kibana-security) (#266614)\n\n## Summary\n\nLazy-load server plugin implementations via `await import('./plugin')`\n(and related entrypoint adjustments) from `server/index.ts`, consistent\nwith https://github.com/elastic/kibana/pull/170856.\n\nThe migration in #170856 reduced **startup time by ~4 seconds** in\nmeasured scenarios. **Memory savings were not quantified but are\nexpected.**\n\n## CODEOWNERS\n\n- `examples/eso_model_version_example` → @elastic/kibana-security\n- `packages/kbn-mock-idp-plugin` → @elastic/kibana-security\n\n## Follow-up\n\n- #171080 — add an ESLint rule\nso new plugins follow this pattern.\n\n---\n\n**Disclaimer:** This PR was prepared with AI assistance (Cursor /\nClaude); please review thoroughly.","sha":"29dbe1df7a1b0b9dfca7371436eff6bf28c1dae7","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v9.4.0","v9.5.0"],"title":"chore: lazy-load server plugin modules (kibana-security)","number":266614,"url":"https://github.com/elastic/kibana/pull/266614","mergeCommit":{"message":"chore: lazy-load server plugin modules (kibana-security) (#266614)\n\n## Summary\n\nLazy-load server plugin implementations via `await import('./plugin')`\n(and related entrypoint adjustments) from `server/index.ts`, consistent\nwith https://github.com/elastic/kibana/pull/170856.\n\nThe migration in #170856 reduced **startup time by ~4 seconds** in\nmeasured scenarios. **Memory savings were not quantified but are\nexpected.**\n\n## CODEOWNERS\n\n- `examples/eso_model_version_example` → @elastic/kibana-security\n- `packages/kbn-mock-idp-plugin` → @elastic/kibana-security\n\n## Follow-up\n\n- #171080 — add an ESLint rule\nso new plugins follow this pattern.\n\n---\n\n**Disclaimer:** This PR was prepared with AI assistance (Cursor /\nClaude); please review thoroughly.","sha":"29dbe1df7a1b0b9dfca7371436eff6bf28c1dae7"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/266614","number":266614,"mergeCommit":{"message":"chore: lazy-load server plugin modules (kibana-security) (#266614)\n\n## Summary\n\nLazy-load server plugin implementations via `await import('./plugin')`\n(and related entrypoint adjustments) from `server/index.ts`, consistent\nwith https://github.com/elastic/kibana/pull/170856.\n\nThe migration in #170856 reduced **startup time by ~4 seconds** in\nmeasured scenarios. **Memory savings were not quantified but are\nexpected.**\n\n## CODEOWNERS\n\n- `examples/eso_model_version_example` → @elastic/kibana-security\n- `packages/kbn-mock-idp-plugin` → @elastic/kibana-security\n\n## Follow-up\n\n- #171080 — add an ESLint rule\nso new plugins follow this pattern.\n\n---\n\n**Disclaimer:** This PR was prepared with AI assistance (Cursor /\nClaude); please review thoroughly.","sha":"29dbe1df7a1b0b9dfca7371436eff6bf28c1dae7"}}]}] BACKPORT--> Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
1 parent 5f563d5 commit b2e3975

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

examples/eso_model_version_example/server/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*/
99

1010
import type { PluginInitializer } from '@kbn/core/server';
11-
import { EsoModelVersionExample } from './plugin';
1211

13-
export const plugin: PluginInitializer<void, void> = async () => new EsoModelVersionExample();
12+
export const plugin: PluginInitializer<void, void> = async () => {
13+
const { EsoModelVersionExample } = await import('./plugin');
14+
return new EsoModelVersionExample();
15+
};

packages/kbn-mock-idp-plugin/moon.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dependsOn:
3636
- '@kbn/core-http-server'
3737
- '@kbn/core-http-server-utils'
3838
- '@kbn/i18n'
39+
- '@kbn/core'
3940
tags:
4041
- plugin
4142
- dev

packages/kbn-mock-idp-plugin/server/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10+
import type { PluginInitializerContext } from '@kbn/core/server';
11+
1012
import { ConfigSchema } from './config';
1113

1214
export type { CreateSAMLResponseParams } from './plugin';
13-
export { plugin } from './plugin';
15+
16+
export const plugin = async (initializerContext: PluginInitializerContext) => {
17+
const { plugin: initPlugin } = await import('./plugin');
18+
return initPlugin(initializerContext);
19+
};
1420

1521
export const config = {
1622
schema: ConfigSchema,

packages/kbn-mock-idp-plugin/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
"@kbn/core-http-server",
2626
"@kbn/core-http-server-utils",
2727
"@kbn/i18n",
28+
"@kbn/core",
2829
]
2930
}

0 commit comments

Comments
 (0)