Question: Auto-load modules, functions, variables

Would it make sense to just auto-load modules, functions and variables into UD endpoints?

I’ve been hosting some stuff in Azure lately and since nothing is on the PSModulePath by default, it’s hard to the the New-UDEndpointInitialization correct. It might be kinda nice to just load everything thats in the default runspace into the endpoints.

What does every one think?

  • Autoload
  • Don’t Autoload

0 voters

I am leaning toward autoload too although it would be nice to keep the flexibility to not autoload based on an environment variable.

For instance, Azure use that idea when you have both the AzureRM module and new Azure module to avoid the wrong one to be loaded.
By setting:
$env:SkipAzInstallationChecks=$true
it becomes your responsibility to import the proper one.

I could see a
$env:SkipUDEndpointInitiialization=$true as a way to not load automatically everything.

That would both provide users with the ease of use and intuitivity brought by an auto-load feature while leaving the possibility to disable it in case it causes performances issues by loading things you would rather not or potentially for debug purposes in rare occasion (For instance, dashboard is slow, you don’t understand why, disable auto-loading then pin-point that a specific module preloaded through your default profile is imported into UD and causing some mahem).

It might be superfluous… or not.
This should be a single check in any case.
Just a thought.

2 Likes

PR in for this. https://github.com/ironmansoftware/universal-dashboard/pull/1132

This is how it’s gonna work. Auto-load is on my default. If you use New-UDEndpointInitialization, it will not auto-load and will use whatever you put in there. New-UDEndpointInitialization can be called without any parameters so that would create a blank slate.

There isn’t any notable performance degradation in my tests. The discovery and endpoint configuration only happens once you start the dashboard.

1 Like

So, any modules available on the host, and any functions you include anywhere in the dashboard, is available to the entire Dashboard?
Sounds good.

Yeah. For example:

Import-Module SomeModule
Import-Module .\SomePath\ToAModule.psm1
function Get-Stuff {}
$ThisIsMyVariable = "Hello!"

$Dashboard = New-UDDashboard -Content {
   New-UDElement -Tag 'div' -Endpoint {
       # All the things just work here!! 🎉
   } 
}

Start-UDDashboard -Dashboard $Dashboard
1 Like