# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1678021628 -3600
# Node ID d238633a9d6781fa2a3818ad27318f5a616300d2
# Parent  cdb996637b084f5f675ee6f4329af2edc47db10b
core.moduleapi: Record reverse dependencies

Useful to know why a module was auto-loaded without having to dig trough
all other modules for the one that depends on it.

diff -r cdb996637b08 -r d238633a9d67 core/moduleapi.lua
--- a/core/moduleapi.lua	Sat Mar 04 18:40:43 2023 +0100
+++ b/core/moduleapi.lua	Sun Mar 05 14:07:08 2023 +0100
@@ -169,6 +169,10 @@
 		end
 	end
 	self.dependencies[name] = true;
+	if not mod.module.reverse_dependencies then
+		mod.module.reverse_dependencies = {};
+	end
+	mod.module.reverse_dependencies[self.name] = true;
 	return mod;
 end