Use composer to install the colorbox and dompurify library

Created on 12 April 2017, over 7 years ago
Updated 27 June 2023, over 1 year ago

Problem/Motivation

Currently, colorbox drupal module requires the colorbox third party Javascript library be manually installed. For Drupal sites using composer, this should be automated and standardized to minimize installation effort and support.

Proposed resolution

  1. Create a "composer.libraries.json" file similar to Webform module that defines the 3rd party library and where it should be installed.
  2. Update installation instructions on how to use composer to install the library by using composer-merge-plugin and making a small edit to the website's main composer.json file.

Remaining tasks

  1. Get maintainer approval on the approach.
  2. Write patch.
  3. Commit, release, and cross fingers... because it is nearly impossible to test patches that affect composer-related files (like composer.json and composer.libraries.json) until they're into the codebase.

User interface changes

None.

API changes

None. The module will now have more control over the suggested/required version of the 3rd party library, and will be responsible for keeping the version up-to-date in a single place.

Data model changes

None.

Original report

There are some composer issues out there, this one might be related.

I installed colorbox library by using composer require kraksoft/colorbox
which results in the library being saved under PROJECT_ROOT/vendor/kraksoft/colorbox
while drupal is under PROJECT_ROOT/web.

The library however is not detected and is not loaded.

Is this installation way supported?

πŸ“Œ Task
Status

Needs work

Version

2.0

Component

Documentation

Created by

πŸ‡¬πŸ‡·Greece bserem

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.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    FYI this repository definition worked for DOMPurify:

            "cure53/dompurify": {
                "type": "package",
                "package": {
                    "name": "cure53/dompurify",
                    "version": "3.0.3",
                    "type": "drupal-library",
                    "dist": {
                        "url": "https://github.com/cure53/dompurify/archive/3.0.3.zip",
                        "type": "zip"
                    }
                }
            },
    
  • πŸ‡ΊπŸ‡ΈUnited States inversed

    If it helps, I think the documentation on the anchor_link β†’ project page is well written. It explains how to do this with wikimedia/composer-merge-plugin in composer or in other ways. This is an old ticket and, at some point, that plugin was not usable (maybe during one of the Drupal major release transitions) but it is working very well now. However, right now, with Drupal 10, I am using the composer.libraries.json approach for both Anchor Link 3.0.0-alpha1 and Webform 6.2.2.

    Something else that may have be causing confusion is the issue mentioned in #41. The Colorbox documentation shown on the Status Report and the Project page is subtly incorrect. On case-sensitive operating systems like Linux, "libraries/DOMPurify/dist/purify.min.js" is going to fail because the module is actually looking for "libraries/dompurify/dist/purify.min.js". So, yes, that is an unrelated problem

  • πŸ‡ΊπŸ‡ΈUnited States firewaller

    +1

  • πŸ‡§πŸ‡ͺBelgium vincent@fontaine.online

    If it helps, here is how I installed DOMPurify with composer :

    composer config repositories.assets composer https://asset-packagist.org
    composer config --unset repositories.0
    composer config repositories.drupal composer https://packages.drupal.org/8
    composer config --json extra.installer-types '["npm-asset", "bower-asset"]'
    composer config --json extra.installer-paths.web\/libraries\/dompurify '["npm-asset/dompurify"]'
    composer config --unset extra.installer-paths.web\/libraries\/\{\$name\}
    composer config --json extra.installer-paths.web\/libraries\/\{\$name\} '["type:drupal-library", "type:bower-asset", "type:npm-asset"]'
    composer require npm-asset/dompurify
    composer require bower-asset/colorbox
Production build 0.71.5 2024