Right now, the tota11y.libraries.yml for this module is setup to load the tota11y JS library from /libraries/tota11y/tota11y.min.js. However, if you are using composer.json to manage your dependencies and download the entire tota11y library from Github, it is hard to configure the library to be downloaded and placed in that folder structure.
Sample composer.json
{
"repositories": [
{
"type": "package",
"package": {
"name": "local/tota11y",
"version": "dev-master",
"type": "drupal-library",
"dist": {
"type": "zip",
"url": "https://github.com/Khan/tota11y/archive/master.zip"
}
}
}
]
}
When the tota11y JS library is downloaded based on this composer.json, the minified copy of the tota11y library will be in: /libraries/tota11y/build/tota11y.min.js. So I propose that we change the path to the library in the libraries.yml to match this path.
Comments
Comment #2
mrkdboyd commentedHere is a patch to change the library path
Comment #3
mikebell_ commentedI've set aside some time tomorrow (Friday) to review this. Thanks!
Comment #4
mikebell_ commentedI like this approach, I think we can take it a step further as well by including the repository and require in the existing composer.json so you only need to run composer require drupal/tota11y.
We need to consider backwards compatibility for existing users (yes all 3 of them ;)).
Comment #5
mrkdboyd commentedYeah, I agree about adding the library to the composer.json for the module.
I'm not sure how we could maintain backwards compatibility though. If we include these changes as part of an 8.x-2.0 release, rather than a point release for 1.x, I think breaking changes are considered acceptable? And of course, we could document the changes well for anyone updating. Let me know what you think.
And I can create a new patch that includes adding the library to the module's composer.json.
Comment #6
mrkdboyd commentedUpon further review, it may not be possible to use the module's composer.json to require the library. See #2836244: Update documentation for installing via composer and also #2706433: Composer dist problem - with chosen composer.json (false github auth problem), particularly comment #29.
The best approach may just be to document how to add the dependency for the tota11y library to your project's root composer.json, as in this patch: https://www.drupal.org/files/issues/chosen-fix_composer_installation-283...
Comment #8
mikebell_ commentedReally sorry for being so slow on this.
I've pushed a new branch with these changes in 8.x-2.x
I'll try and test it out fully before making a new release.
Comment #9
b-prod commentedThis works file and fix error message when installed using Composer.
Comment #10
codebymikey commentedThe url path should now be
/libraries/tota11y/dist/tota11y.min.jsfor the latest version on npm https://registry.npmjs.org/@khanacademy/tota11y/-/tota11y-0.2.0.tgzComment #11
ikit-claw commentedMerged into 2.0.x-dev If you would like to test it that would be great. https://www.drupal.org/project/tota11y/releases/2.0.x-dev