npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rvc

v0.6.0

Published

RequireJS plugin to load and optimise Ractive components

Downloads

14

Readme

rvc.js

RequireJS supports loader plugins, which allow your AMD modules to specify dependencies that aren't AMD modules, by prefixing the path with the plugin name followed by !.

rvc is one such loader plugin, and it allows you to require component files.

If you're not sure what 'component files' are, have a read of this. If you're not familiar with RequireJS loader plugins, there's some documentation here.

Installation

To get rvc.min.js you can:

  • Use CDN: //cdn.jsdelivr.net/ractive.rvc/latest/rvc.min.js.
  • Use bower: $ bower i rvc.
  • Download the latest release.
  • Clone the repo: $ git clone https://github.com/ractivejs/rvc.git.

Usage

First, RequireJS needs to be able to find rvc.js and ractive.js. Either it should be in the root of your project (or whatever baseUrl is configured to be), or you'll need to set up the paths config (obviously, change the paths as appropriate):

require.config({
  paths: {
    ractive: 'lib/ractive',
    rvc: 'plugins/rvc'
  }
});

Once RequireJS is configured, you can import components like so:

// At the top-level of your app, e.g. inside your main.js file
require([ 'rvc!foo' ], function ( Foo ) {
  var ractive = new Foo({ /* ... */ });
});

// Inside a module
define([ 'rvc!foo' ], function ( Foo ) {
  var ractive = new Foo({ /* ... */ });
});

Note that the .html file extension is omitted - this is assumed.

Component paths work just like regular module paths, so they can be relative (rvc!../foo), or below an entry in the paths config:

require.config({
  paths: {
    ractive: 'lib/ractive',
    rvc: 'plugins/rvc',
    ui: 'path/to/ractive_components'
  }
});

require([ 'rvc!ui/foo' ], function ( Foo ) {
  var ractive = new Foo({ /* ... */ });
});

Optimisation

The great feature of RequireJS is that while you can develop your app without having to rebuild it every time you change a file, you can also bundle it into a single file for production using the optimiser.

In addition to this 'inlining' of your components, rvc will parse your templates so that no additional computation needs to happen in the browser.

Once your project is optimised, you don't need the plugin itself, so add rvc to the stubModules option:

// optimiser config
{
  paths: {
    ractive: 'lib/ractive',
    rvc: 'plugins/rvc'
  },
  stubModules: [ 'rvc' ]
}

Consult the documentation for more information on using the optimiser.

License

MIT.