Use composer to manage library file dependency

Created on 18 October 2023, about 1 year ago
Updated 5 January 2024, 11 months ago

Instead of including jquery.once.min.js with the module, would it not be better to make it a composer (npm-asset) dependency?

๐ŸŒฑ Plan
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom stox

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

Comments & Activities

  • Issue created by @stox
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom stox
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland florianmuellerch Aarau, Switzerland

    Hi @stox!
    Good idea :) I just needed the module asap, that's why I threw it together like that.
    I'm not entirely sure how I could control composer dependencies in particular, especially as Drupal itself does add a composer file when the project is released and packed... Would you or anyone else mind making a PR or a patch with a draft?

    Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    chetan 11 โ†’ made their first commit to this issueโ€™s fork.

  • @chetan-11 opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia chetan 11

    Hi,
    I have added composer file for the above module, please check the raised MR & let me know if anything needs to be added.
    Thanks.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada dalin Guelph, ๐Ÿ‡จ๐Ÿ‡ฆ, ๐ŸŒ

    Why not require "npm-asset/jquery-once": "^2.2" rather than jQuery? It lists jQuery as a dependency, so it'll sort it out (especially if you have a specific version of jQuery required in your root composer.json).

    Also, this commit would need to remove the included files from these libraries, and add some documentation pointing to https://asset-packagist.org/

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada joseph.olstad

    agree with comment #7

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland florianmuellerch Aarau, Switzerland

    I've just released official 1.0 of the module, however I'm totally fine if you get a tested and working solution in your MR, I would merge that and release 1.1 from that.

    I just would like more feedback from people on this, and the MR would have to be adapted.

  • Status changed to Needs review about 1 year ago
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada dalin Guelph, ๐Ÿ‡จ๐Ÿ‡ฆ, ๐ŸŒ

    I don't think the MR can work yet. We still needs some changes mentioned in #7:

    • remove the included files from these libraries in jquery_once/lib
    • the files will then be at /libraries/[library] so jquery_once.libraries.yml will need to be adjusted
    • add some documentation (a README.md?) pointing people to https://asset-packagist.org/ because you need to add a few snippets to your root composer.json
    • bonus: add a hook_requirements()to check if the library is where we expect.
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada RobLoach Earth

    Thanks for putting together the module. I did laugh when I saw it.

    The library is licensed MIT or GPL-2, so there's no problem copy/pasting it directly into the module. Happy to make consumption and maintenance easier. It is available on Packagist as a `component` type:
    https://packagist.org/packages/robloach/jquery-once

    Though, that could complicate things, as it specifies a dependency on components/jquery. Removing the defined dependency may make things easier?

    Also, if anyone wants to help maintain the library, lemme know in the github.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada joseph.olstad

    Ya this module saved one of my clients months of very complicated high-risk js work. I tried refactoring away from jquery once but due to the weakness of the replacement once it just was too complicated.

Production build 0.71.5 2024