Install and use sparkline from composer

Created on 6 July 2020, over 4 years ago
Updated 31 August 2023, about 1 year ago

I don't see any docs on installing sparkline library for this module, so I'm using these drupal.org docs โ†’ .

That installs the library to web/libraries/jquery-sparkline rather than web/libraries/sparkline as the module expects.

So, I'm going to throw a patch here which adjusts for the library path.

An alternate solution which I'm happy to contribute to is that we document the correct procedure to install the sparkline dependency - let me know!

Steps (based on linked docs) below. This can probably be improved on to add a composer.json for this project so it automatically does the final step.

The recipe for setting up Asset Packagist for use in your projects is as follows:

  1. Add the Composer Installers Extender PHP package by oomphinc to your project's root composer.json file, by running the following command:

    composer require oomphinc/composer-installers-extender

  2. Add Asset Packagist to the "repositories" section of your project's root composer.json.

    "repositories": [
        {
            "type": "composer",
            "url": "https://asset-packagist.org"
        }
    ]
  3. Ensure that NPM and Bower assets are registered as new "installer-types" and, in addition to type:drupal-library, they are registered in "installer-paths" to be installed into Drupal's /libraries folder, within the "extra" section of your project's root composer.json file.

    "extra": {
        "installer-types": [
            "npm-asset",
            "bower-asset"
        ],
        "installer-paths": {
            "web/libraries/{$name}": [
                "type:drupal-library",
                "type:npm-asset",
                "type:bower-asset"
            ]
        }
    }
  4. The installation path of a specific library can be controlled by adding it to the "installer-paths" configuration above the general configuration. For example, the chosen module expects the library at /libraries/chosen, but composer require npm-asset/chosen-js installs the library into /libraries/chosen-js; the following override installs it into the expected folder:

    "extra": {
        "installer-paths": {
            "web/libraries/chosen": ["npm-asset/chosen-js"],
            "web/libraries/{$name}": [
                "type:drupal-library",
                "type:npm-asset",
                "type:bower-asset"
            ]
        }
    }
    
  5. You may now require libraries from NPM or Bower via Composer on the command line:

    composer require npm-asset/jquery-sparkline

  6. Contrib and custom modules may include these dependencies in their own respective composer.json files. See Requiring third-party libraries with Composer โ†’ for additional instructions.

โœจ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly finex

    Hi, thanks for the patch. Unfortunately the module settings page does not work on D10 (after manually applying the compatibility patch).

Production build 0.71.5 2024