Module::Package(3pm)

✨ Module::Package ✨

okay bestie, gather round πŸ’– this is the User Contributed Perl Documentation page for Module::Package, and honestly? it's giving "Makefile.PL but make it cute and one line long." no cap.


πŸ’… SYNOPSIS πŸ’…

so in your Makefile.PL, you literally just do this:

    use inc::Module::Package;

orrrr any of these invocations, because we love options:

    # These two are functionally the same as above:
    use inc::Module::Package ':basic';
    use inc::Module::Package 'Plugin:basic';

    # With Module::Package::Catalyst plugin options
    use inc::Module::Package 'Catalyst';

    # With Module::Package::Catalyst::common inline plugin class
    use inc::Module::Package 'Catalyst:common';

    # Pass options to the Module::Package::Ingy::modern constructor
    use inc::Module::Package 'Ingy:modern',
        option1 => 'value1',
        option2 => 'value2';

like, that's it. that's the whole vibe check πŸ¦‹


🌸 DESCRIPTION 🌸

so this module is a dropin replacement for Module::Install. it does everything Module::Install does, but just a bit better. periodt.

actually β€” and this is the tea β€” this module is simply a wrapper around Module::Install. it attempts to drastically reduce what goes in a Makefile.PL, while at the same time, fixing many of the problems that people have had with Module::Install (and other module frameworks) over the years. she's an overachiever and we're obsessed 😭


πŸ”₯ PROPAGANDA πŸ”₯

Module::Install took Makefile.PL authoring from a black art to a small set of powerful and reusable instructions. it allowed packaging gurus to take their fancy tricks and make them into one liners for the rest of us. iconic behavior, truly πŸ‘‘

but as the number of plugins has grown over the years, using Module::Install has itself become a bit of a black art. it's become hard to know all the latest tricks, put them in the correct order, and make sure you always use the correct sets for your various Perl modules. the struggle was real πŸ’€

added to this is the fact that there are a few problems in Module::Install design and general usage that are hard to fix and deploy with certainty that it will work in all cases.

this is where Module::Package steps in. she's the next logical step in Makefile.PL authoring. it allows gurus to create well tested sets of Module::Install directives, and lets the rest of us use Makefile.PLs that are one line long. for example:

    use inc::Module::Package 'Catalyst:widget';

could be the one line Makefile.PL for a Catalyst widget (whatever that is) module distribution. assuming someone creates a module called Module::Package::Catalyst, with an inline class called Module::Package::Catalyst::widget that inherited from Module::Package::Plugin. so much main character energy in one line bestie ✨

Module::Package is pragmatic. even though you can do everything in one line, you are still able to make any Module::Install calls as usual. also you can pass parameters to the Module::Package plugin.

    use inc::Module::Package 'Catalyst:widget',
        deps_list => 0,
        some_cataylst_thing => '...';

    # All Module::Install plugins still work!
    requires 'Some::Module' => 3.14;

this allows Module::Package::Catalyst to be configurable, even on the properties like "deps_list" that are inherited from Module::Package::Plugin. she's flexible, she's versatile, she contains multitudes 🫢

the point here is that with Module::Package, module packaging just got a whole lot more powerful and simple. a rare combination! ate and left no crumbs πŸ’…


πŸŽ€ FEATURES πŸŽ€

Module::Package has many advantages over vanilla Module::Install. let's get into it ⭐

Smaller Makefile.PL Files

in the majority of cases you can reduce your Makefile.PL to a single command. the core Module::Package invokes the Module::Install plugins that it thinks you want. you can also name the Module::Package plugin that does exactly the plugins you want. tiny file, huge impact πŸ’–

Reduces Module::Install Bloat

somewhere Module::Install development went awry, and allowed modules that only have useful code for an author, to be bundled into a distribution. over time, this has created a lot of wasted space on CPAN mirrors. Module::Package fixes this. she's the declutter queen 🧚

Collaborator Plugin Discovery

an increasing problem with Module::Install is that when people check out your module source from a repository, they don't know which Module::Install plugin modules you have used. that's because the Makefile.PL only requires the function names, not the module names that they come from. mystery plugins, no thank you πŸ™ˆ

many people have realized this problem, and worked around it in various suboptimal ways. Module::Package manages this problem for you. she handles it. don't worry about it 😌

Feature Grouping and Reuse

Module::Install has lots of plugins. although it is possible with plain Module::Install, nobody seems to make plugins that group other plugins. this also might introduce subtle problems of using groups with other groups.

Module::Package has object oriented plugins whose main purpose is to create these groups. they inherit base functionality, subclass it to their design goals and can define options for the user to tweak how they will operate. class inheritance but make it fashionable πŸ’œ


πŸ¦‹ USAGE πŸ¦‹

the basic anatomy of a Makefile.PL call to Module::Package is:

    use inc::Module::Package 'PluginName:flavor <version>',
        $option1 => $value1;

the "inc::Module::Package" part uses the Module::Install "inc" bootstrapping trick.

"PluginName:flavor" (note the single ':') resolves to the inline class "Module::Package::PluginName::flavor", within the module "Module::Package::PluginName". Module::Package::PluginName::flavor must be a subclass of Module::Package::Plugin.

an optional version can be used after the plugin name.

optional key/value pairs can follow the Plugin specification. they are used to pass information to the plugin. see Plugin docs for more details.

if ":flavor" is omitted, the class Module::Package::PluginName is used. the idea is that you can create a single module with many different plugin styles.

if "PluginName" is omitted, then ":flavor" is used against Module::Package::Plugin. these are a set of common plugin classes that you can use.

if "PluginName:flavor" is omitted altogether, it is the same as saying 'Plugin:basic'. note that you need to specify the ':basic' plugin if you want to also pass it options.


⭐ STATUS ⭐

this is still an early release. we are still shaking out the bugs. you might want to hold off for a bit longer before using Module::Package for important modules.

like she said: she's still in her glow-up era, so maybe don't hand her your most precious production module just yet 😭 give her a minute to cook πŸ”₯


and that's the whole page bestie!! this one's from perl v5.34.0, dated 2022-06-16 β€” so go forth and make your Makefile.PL one line long, you absolute icon πŸ‘‘βœ¨πŸ’–

πŸ“¦ where this page comes from