How to design a Godot DLC / mini-game system that can use classes and scenes from the main project with static typing?

Imagine I want to build a game lobby using Godot that can dynamically load various mini-games, each also made with Godot. Ideally, when a mini-game exits, it should be possible to fully unload it from memory.

How should I design such a system so that the mini-games can use classes, scenes, or other resources provided by the main lobby project?

Additionally, I would like the mini-game code to be statically typed when being written (for example in GDScript), rather than relying on purely dynamic access.

I have already read the following article:

However, if I write code like the following inside the DLC project, it fails to compile:

extends “res://sdk/class_in_main.gd“

load(“res://sdk/class_in_main.gd“)

preload(“res://sdk/class_in_main.gd“)

Should I include stub / empty implementations of the SDK code inside the DLC project?

If so, how can I ensure that the DLC does not package the SDK implementation itself, and instead uses the implementation provided by the main application when the DLC is loaded or executed?

I have the same issue when trying to access other resources from the main application, such as scenes.
How should this kind of resource sharing be handled in this architecture?