From 796ca2718967e7a075aa64d6ae84f2beef8e40e2 Mon Sep 17 00:00:00 2001 From: Thomas Taylor Date: Mon, 13 Apr 2026 15:48:06 +0100 Subject: [PATCH] Lazy-load UiBuild to speed up server startup UiBuild.js eagerly imports rollup, babel, less, terser, handlebars, and other build tooling at module level. These are only needed when actually building the UI, which happens after app.onReady(). Convert the top-level `import UiBuild from './UiBuild.js'` to a dynamic `await import('./UiBuild.js')` inside the build() method, deferring the heavy dependency tree until the first build runs. Reduces this module's import time from ~2.6s to ~242ms. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/UiModule.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/UiModule.js b/lib/UiModule.js index 865f5499..0acfacb0 100644 --- a/lib/UiModule.js +++ b/lib/UiModule.js @@ -1,6 +1,6 @@ import { AbstractModule, Hook } from 'adapt-authoring-core' import path from 'path' -import UiBuild from './UiBuild.js' + /** * The main entry-point for the Adapt authoring tool web-app/front-end * @memberof ui @@ -75,6 +75,7 @@ class UiModule extends AbstractModule { * @return {Promise} */ async build () { + const { default: UiBuild } = await import('./UiBuild.js') const build = new UiBuild({ app: this.app, log: this.log.bind(this),