Closed TsekNet closed 4 years ago
As mentioned here this is done on purpose.
There are local development scenarios where the psm1 may be called directly.
The documentation for Export-ModuleMember covers this in more detail:
If a script module does not include an Export-ModuleMember command, the functions and aliases in the script module are exported, but the variables are not. When a script module includes Export-ModuleMember commands, only the members specified in the Export-ModuleMember commands are exported. You can also use Export-ModuleMember to suppress or export members that the script module imports from other modules. An Export-ModuleMember command is optional, but it is a best practice. Even if the command confirms the default values, it demonstrates the intention of the module author.
Feel free to reopen this if you have additional concerns.
Expected Behavior
Catesta already exports module members via the module manifest, there is no need to add Export-ModuleMember to the module as well. By default, creating a new module will fail due to the PSScriptAnalyzer rule that does not allow for wildcard exports in the module manifest, so this field must be modified for all modules to build successfully.
Current Behavior
Catesta executes
Export-ModuleMember -Function $public.Basename
as part of every time the module is imported (link).Possible Solution
Remove
Export-ModuleMember
from the module itself, and leave this to the manifest. I will submit a PR for this.Steps to Reproduce
Context (Environment)
$PSVersionTable.OS
:$PSVersionTable.PSEdition
:Detailed Description
I'll note that this is not a high priority issue, this technically works, just the effort is duplicated. For context, this suggestion was taken from this Reddit post.