Problem/Motivation
The module works great to define new namespaces. We had a similar situation with the custom implementation of the storybook. It was done in a custom module in a similar situation to the https://medium.com/@askibinski/integrating-storybook-with-drupal-ddabfc6...
However, this custom module also contained different libraries in its sub-directories. I have a limited understanding of the internals of storybook, but there are a lot of libraries defined in them. It would be good if there was a way to autoload them as they seem to be dynamic and pretty tough to be included in the module's *.libraries.yml
Proposed resolution
Provide a new option to automatically detect the libraries. In the following way:
components:
namespaces:
myLib:
- myLibFiles
autodetect_libraries:
- myLib
Remaining tasks
Patch and review.
User interface changes
None.
API changes
New option added to the yaml file.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3348158-autoload-8.patch | 4.19 KB | mikeryan |
| #5 | interdiff.txt | 2.28 KB | alecsmrekar |
| #5 | 3348158-autoload-5.patch | 3.83 KB | alecsmrekar |
| #3 | interdiff.txt | 1.05 KB | ajits |
| #3 | 3348158-autoload-3.patch | 3.6 KB | ajits |
Issue fork components-3348158
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3348158-autodetect-libraries
changes, plain diff MR !43
Comments
Comment #2
ajitsAdded a patch with the functionality.
Comment #3
ajitsHandled an error thrown
Comment #4
stefanos.petrakisIt looks good.
Maybe we can be more defensive regarding the
$extension_pathvariable?As in, if still an empty string, do not enter the main loop.
Comment #5
alecsmrekar commentedUpdating the patch to read from the module/theme list service, instead of reading from cache directly. I also incorporated feedback from Stefanos.
Comment #6
alecsmrekar commentedComment #7
robloachThanks for all the work here, everyone. How does this approach differ from https://www.drupal.org/project/components/issues/2707849 ?
Comment #8
mikeryanRerolled patch for the new README.
Comment #10
ajitsCreated a PR as we're moving away from d.o issues. See - #3295357: Migrate drupal.org issues to GitLab issues
Comment #11
dpiSince theres no direct answer to #7, closing this so there is no wasted effort in this issue, compared to the long-lived/discussed/followed issue at #2707849: Allow components to define asset libraries.
Please open if differences can be justified.