Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore using composer merge plugin to install js_cookie #4555

Open
jfrank-nih opened this issue Jan 23, 2025 · 0 comments
Open

Explore using composer merge plugin to install js_cookie #4555

jfrank-nih opened this issue Jan 23, 2025 · 0 comments

Comments

@jfrank-nih
Copy link
Member

We have added js-cookie as a "repository" of type "drupal-library" which forces Drupal to download the JavaScript to docroot/libraries and then include it into the JS package for the site. (Based on this comment.) This was done for #4505 to stop the library from loading from a CDN. (PR #4551)

"js-cookie": {
"type": "package",
"package": {
"name": "js-cookie/js-cookie",
"version": "3.0.5",
"type": "drupal-library",
"dist": {
"url": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
"type": "tar",
"shasum": "0b7e2fd0c01552c58ba86e0841f94dc2557dcdbc"
}
}
}
},

In reality it would be best if the version of js-cookie was managed by the JS Cookie module itself. We are waiting on issue 339061 to be completed via this merge request.

If that goes through then the best option is probably to do the following (from their readme):

Install library via composer (Merge Plugin)

If you are using the Composer Merge Plugin you can add the composer.libraries.json to your project's composer.json:

"extra": {
  "merge-plugin": {
    "include": [
      "web/modules/contrib/js_cookie/composer.libraries.json"
    ]
  }
}

Then use the following command:

composer update 'js_cookie/js_cookie'

For more information see How to use composer to install libraries for the Webform module, which takes a similar approach to using composer.libraries.json.

Doing this allows the version of JS Cookie that we have installed by managed by the module itself. Otherwise if the module changes we are left with an orphaned JS cookie library still being installed.

This does require exploring the composer merge plugin, which would be required to utilize this.

@jfrank-nih jfrank-nih changed the title Use composer merge plugin to install js_cookie Explore using composer merge plugin to install js_cookie Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant