Author Topic: Using JS Components in a RC plugin  (Read 3201 times)

Offline mitya

  • Newbie
  • *
  • Posts: 1
Using JS Components in a RC plugin
« on: February 13, 2017, 05:51:46 AM »
Hi,

There's a repo of popular JS libraries packaged for Composer and published at Packagist: https://github.com/components

I'd like to use one of these libraries in my RC plugin. This would allow to avoid polluting my plugin repo with redundant JS code, and would make updating to the new versions easier. There's no problem introducing a dependency in my composer.json, but the problem is that the library gets installed into the $RC_ROOT/vendor subdir, and therefore is not accessible as a web resource by default. I've yet come up with a post-install script that creates a symlink $RC_ROOT/plugins/my_plugin/foo_lib -> $RC_ROOT/vendors/components/foo_lib

However, it seems a bit hacky to me. Can anyone suggest a better solution?

Maybe enhancing plugin-installer so that it automatically installs a symlink into plugin directory if it encounters a "component" package type? What do you think?

Cheers,
Mitya

P.S. Disclaimer: I'm a co-author and a maintainer of the RoundCube JSXC chat plugin (yet to be published - we've decided to resolve dependency issue prior to officially publishing the plugin). The library under study is JSXC itself. Together with JSXC author, we've decided to publish it as a component, in order to improve maintainability of PHP projects that might depend on JSXC, including the RC plugin proper.
« Last Edit: February 13, 2017, 03:28:53 PM by mitya »