From 7839d529253ec97224e126b5cf66865ebf2c63e4 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Mon, 9 Dec 2024 13:14:10 -0500 Subject: [PATCH] dev: address TODO comment in Kernel.js --- src/backend/src/Kernel.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/backend/src/Kernel.js b/src/backend/src/Kernel.js index 83fce3057..f99cafd31 100644 --- a/src/backend/src/Kernel.js +++ b/src/backend/src/Kernel.js @@ -294,6 +294,13 @@ class Kernel extends AdvancedBase { const mod = new ExtensionModule(); mod.extension = new Extension(); + const mod_context = this._create_mod_context(mod_install_root_context, { + name: mod_dirname, + ['module']: mod, + external: true, + mod_path, + }); + // This is where the module gets the 'use' and 'def' globals await this.useapi.awithuse(async () => { // This is where the module gets the 'extension' global @@ -304,21 +311,6 @@ class Kernel extends AdvancedBase { if ( maybe_promise && maybe_promise instanceof Promise ) { await maybe_promise; } - }); - }); - - const mod_context = this._create_mod_context(mod_install_root_context, { - name: mod_dirname, - ['module']: mod, - external: true, - mod_path, - }); - - // TODO: DRY `awithuse` and `aglobalwith` with above - await this.useapi.awithuse(async () => { - await useapi.aglobalwith({ - extension: mod.extension, - }, async () => { // This is where the 'install' event gets triggered await mod.install(mod_context); });