Extend Export-ModuleMember to Support Enums, Classes, Interfaces, and DSC Resources #88
michaeltlombardi
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, for a user to take advantage of enums or classes defined in a PowerShell module, they need to:
using module <module name>
to load all of the types from that moduleAlternatively, the module author can add a script in the ScriptsToProcess key of their module manifest which specifies the
using
statement for them.For types which are included in a module and not meant to be exported, this is a reasonable UX - the user has to opt in to use a component not intended for direct/common consumption (but also not prevented from doing so - though there's no way to implement private classes or enums in PowerShell today). However, as a module author, if I want to export a type for my users, the only way to do so is with the ScriptsToProcess workaround.
Further, this would help move DSC Resource discovery from a special case towards a normal exported member of a PowerShell module.
Proposal
I propose that the
Export-ModuleMember
cmdlet be extended to support enums, classes (and by extension, DSC Resources), and (if #83 is implemented) interfaces. Ideally, this would come along with the ability to unload these types when the module is removed.Optionally, this import behavior would require an opt-in switch parameter on
Import-Module
like LoadTypes - this is probably necessary if unloading is not feasible or implemented.Beta Was this translation helpful? Give feedback.
All reactions