These are chat archives for ractivejs/ractive

5th
Jul 2018
Joseph
@fskreuz
Jul 05 2018 15:44
@ceremcem i haven't looked into it. I'm also lacking in the politics department. :grin:
Nice to know Ractive is being used in these kinds apps. This joins the other politics-related apps powered by Ractive, notably The Guardian's 2016 US election map.
In other news, a new toolkit has been linked on the docs site! https://aldi.github.io/ralma/
kouts
@kouts
Jul 05 2018 15:46
Nice!
Cerem Cem ASLAN
@ceremcem
Jul 05 2018 20:37
thanks...
Shakeel Osmani
@shakeelosmani
Jul 05 2018 20:50
I have a question I see till upto RactiveJS vs .8 there were individuals who wrote plugins and components and made them available as node modules. Is this still possible. Is there an example I can follow and publish some of the components that I have been writing and that use popular 3rd party libraries. It will benefit those who need those libraries integrated also I am a newbie and community can refactor the code or provide comments to make them better.
Chris Reeves
@evs-chris
Jul 05 2018 21:12
It's definitely still possible, and there's even a generic plugin format now available via use. It's a bit under documented at the moment though. It's a bit harder to publish modules with all of the different formats these days, especially with those formats that don't support declarative dependencies. The use-style plugins aim to mitigate that a bit, as they supply the Ractive lib to the plugin function.
Shakeel Osmani
@shakeelosmani
Jul 05 2018 21:16
@evs-chris for example i have a select to component here select2 . How the use-style plugin play a role here in making it available as a lib
Chris Reeves
@evs-chris
Jul 05 2018 21:52
in the case of third-party integrations, there's not really a great way to publish those as modules unless you are targeting a specific module system(s)
it's challenging to cover all of the cases nicely, and in this case, you need jquery and a plugin already in place before your ractive plugin can be loaded
at this point, my approach has been to support es6 with a bundler and pseudo umd, where the deps (jquery and the plugin) are provided to the plugin function exported by my module
so you get something like this:
export default plugin(opts) {
  const extend = {
    template: '...',
    on: { init() { ... }, ... },
    ...
  };
  return function({ Ractive, target }) {
    target.components[opts.name || 'mycomponent'] = Ractive.extend(extend);
  };
}
Chris Reeves
@evs-chris
Jul 05 2018 21:59
which is then used
import mycomponent from 'wherever';
new Ractive({ use: [mycomponent({ name: 'somename', jquery, .... })] });

ideally the module would be able to declare its deps up from with plain old

import jquery from 'jquery';

and the like, but in practice, that cuts out a pretty big chunk of the web that is just throwing stuff into a <script> tag

Shakeel Osmani
@shakeelosmani
Jul 05 2018 22:06
Understood. So for sometime to come having these in github is good enough, and if people search for it they will find it.