- 🇳🇿New Zealand kent@passingphase.nz
I was not able to get this working by any of the methods outlined. Instead I am using this library: https://github.com/oomphinc/composer-installers-extender and ensured that my type name is prefixed with 'drupal-'. No need for any fancy packages in repositories or anything. Just ensure that the type name used in the custom module/library is the same as the one you want to save to your custom directory:
e.g in the module
{ "name": "myproject/mymodule", "type": "drupal-myproject-custom-module", ... }
And in the root composer.json:
"web/modules/myproject/{$name}": [ "type:drupal-myproject-custom-module" ],
- 🇵🇹Portugal jcnventura
@NewZeal, this thread is about installing the Javascript libraries required by this module, and not a custom module.
To install a custom module, you should not need to use "oomphinc/composer-installers-extender", but can instead use the "composer/installers" library, and give your module the standard "drupal-custom-module" type. See https://www.drupal.org/docs/develop/creating-modules/add-a-composerjson-... → for more information.
- 🇳🇿New Zealand kent@passingphase.nz
My apologies. Actually, my intention is to install in a custom folder and not the standard "drupal-custom-module", for which the solution I provided seems essential.
- 🇵🇹Portugal jcnventura
It's a bit off-topic, but if you are OK with installing all your drupal-custom-module in the same directory, you should be fine with the base composer/installers package, and setting the directory in https://github.com/drupal/recommended-project/blob/10.1.x/composer.json#L54
Of course, if you want to install drupal-custom-module in web/modules/custom and some other custom module in web/modules/myproject, the yes, you need to define your own type for this drupal-myproject-custom-module cases. It does seem a bit too many levels of custom modules, but I'm pretty sure if you need that, that there are good reasons for it.
- 🇳🇿New Zealand kent@passingphase.nz
Yes, the reason for the custom folder is that the module has its own git repo that is made available as a package from gitlab, therefore it is not to be altered within the current repo. Meanwhile all modules under custom folder belong to the current repo and should be altered as required within the current repo.
- 🇧🇪Belgium ludo.r Brussels
For me it worked like this:
Add this to composer.json
"extra": { "merge-plugin": { "include": [ "[web-root]/modules/contrib/ckwordcount/composer.libraries.json" ] } }
And then
composer require drupal/ckwordcount
and notcomposer require drupal/ckwordcount w8tcha/ckeditor-wordcount-plugin
.