dinbror / blazy

Hey, be lazy! bLazy.JS is a lightweight pure JavaScript script for lazy loading and multi-serving images. It's working in all modern browsers including IE7+.
http://dinbror.dk/blazy
MIT License
2.63k stars 355 forks source link

Make bLazy available via composer? #168

Open gormus opened 6 years ago

gormus commented 6 years ago

Hi, I'm the developer of Lazy-load, a Drupal module which integrates bLazy script. I'd like to define the bLazy library a dependency and have it installed automatically when the module is installed via composer. (Composer is Drupal's choice for managing packages.) Currently, bLazy library must be downloaded manually and copied into Drupal's libraries folder.

Beside my module, there are several other Drupal modules integrate bLazy with Drupal, quite positive they all could benefit from this.

Would you consider making bLazy available as a composer package?

If you are not familiar with Composer just yet, you may want to check out https://getcomposer.org/ and https://packagist.org/

Thanks,

Kingdutch commented 6 years ago

You can already install this by requiring bower-asset/blazy^1.8 after adding the following to the repositories key in your root composer.json file:

        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }

Open Social did something like this already and blogged about it here: https://www.getopensocial.com/blog/drupal-world/changing-third-party-library-inclusion

gormus commented 6 years ago

It's a real good suggestion, and I probably will use it for some other projects, thank you for sharing.

Unfortunately though that doesn't help resolving my issue. I was looking for a solution without requiring any changes in the ROOT composer.json file. That could happen only when this project has a valid (and registered?) composer.json file in their root.

Now, in my module's documentation I recommend adding a package definition in the repositories section of composer.json:

    {
        "type": "package",
        "package": {
            "name": "dinbror/blazy",
            "version": "1.8.2",
            "type": "drupal-library",
            "extra": {
              "installer-name": "blazy"
            },
            "source": {
                "type": "git",
                "url": "https://github.com/dinbror/blazy",
                "reference": "1.8.2"
            }
        }
    }

Complete instructions can be found at https://www.drupal.org/project/lazy#Installing_via_Composer_31