Migrate from clikt (Mordant) to clikt-core module (has no dependencies) to reduce bundle size
Recently CliKt, which is a Kotlin Multiplatform command line interface parser and formatted, introduced Mordant as a dependency in Mordant 4.X which has dependencies that increase the size around 8-10 MB (See CliKt Issue #507 for more details).
CliKt was originally a command line parser similar to Kotlinx CLI and Kotlin Args Parser, though with each major release, it introduced new features and capabilities, Kobweb CLI use CliKt as a dependency for parsing the commands and formatting the output.
Kobweb CLI uses Kotter primarily as a CLI dependency which has its own dependencies.
Recently in CliKt 5.X (which hasn't been released yet and is available as 4.4.0.20-SNAPSHOT) introduced a new module called clikt-core in CliKt PR #516 that has no dependencies.
Notice that:
The core module is published as clikt-core and called clikt as the directory/module name in the repository
The mordant module is published as clikt and called clikt-mordant as a directory/module name in the repository.
The size has been reduced from 23.1 MB to 12.5 MB, saving approximately 46% (around 10.6 MB).
A few things to keep in mind:
Formatter: The code now is using PlaintextHelpFormatter instead of MordantHelpFormatter which is the default for CliKt Mordant (clikt module). PlaintextHelpFormatter doesn't support text wrapping, markdown, or any other styles or formatting as the docs say. For details, take a look at PlaintextHelpFormatter docs for details.
NoOpCliktCommand class: This class does not seem to be Mordant specific, though it seems it's in com.github.ajalt.clikt.core package from clikt-mordant, this class seems to override run function with no statements or code in it, I declared a class with the same name and code NoOpCliktCommand which will be used by Kobweb to inherit from. Added a TODO in case this class moved from clikt to clikt-core. The NoOpCliktCommand has been moved to clikt-core. See Clikt PR #526.
The Kotlin version in the file idea/kotlinc.xml is still 1.8.10 while this PR uses 2.0.0.
The latest version of CliKt that has the clikt-core require at least Kotlin 2.0.0.
Migrate from clikt (Mordant) to clikt-core module (has no dependencies) to reduce bundle size
Recently CliKt, which is a Kotlin Multiplatform command line interface parser and formatted, introduced Mordant as a dependency in Mordant 4.X which has dependencies that increase the size around 8-10 MB (See CliKt Issue #507 for more details).
CliKt was originally a command line parser similar to Kotlinx CLI and Kotlin Args Parser, though with each major release, it introduced new features and capabilities, Kobweb CLI use CliKt as a dependency for parsing the commands and formatting the output.
Kobweb CLI uses Kotter primarily as a CLI dependency which has its own dependencies.
Recently in CliKt 5.X (which hasn't been released yet and is available as
4.4.0.20-SNAPSHOT
) introduced a new module calledclikt-core
in CliKt PR #516 that has no dependencies.Notice that:
clikt-core
and calledclikt
as the directory/module name in the repositoryclikt
and calledclikt-mordant
as a directory/module name in the repository.The size has been reduced from 23.1 MB to 12.5 MB, saving approximately 46% (around 10.6 MB).
A few things to keep in mind:
PlaintextHelpFormatter
instead ofMordantHelpFormatter
which is the default for CliKt Mordant (clikt
module).PlaintextHelpFormatter
doesn't support text wrapping, markdown, or any other styles or formatting as the docs say. For details, take a look atPlaintextHelpFormatter
docs for details.. TheNoOpCliktCommand
class: This class does not seem to be Mordant specific, though it seems it's incom.github.ajalt.clikt.core
package fromclikt-mordant
, this class seems to overriderun
function with no statements or code in it, I declared a class with the same name and codeNoOpCliktCommand
which will be used byKobweb
to inherit from. Added a TODO in case this class moved fromclikt
toclikt-core
NoOpCliktCommand
has been moved toclikt-core
. See Clikt PR #526.The Kotlin version in the fileidea/kotlinc.xml
is still1.8.10
while this PR uses2.0.0
.The latest version of CliKt that has the
clikt-core
require at least Kotlin 2.0.0.