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

circus-router

v1.1.1

Published

Router parser for Circus components

Downloads

6

Readme

circus-router

In-source router parser for Circus components dependencies, allowing for smart runtime behavior such as demand loading of chunks based on the current route. This allows the application to bootstrap from minimal code sent to the client, with only the pertinent code being loaded when the user hits that portion of the site.

Usage

See the example directory for an example of a complete Backbone application.

Configuration

Used as a preprocessor for the Circus.config method:

var Circus = require('circus'),
    CircusRouter = require('circus-router');

var config = {};
config = CircusStylus.config(config);
config = Circus.config(config);

Routers

Routers are the primary execution component for Circus applications. As in generic backbone applications, they allow for specific behaviors to occur in response to the current url of the page.

Circus.router({
  routes: {
    '/': 'home',
    '/home': 'home'
  },

  home: function(params) {
    // Respond to the route
  }
});

Defines a [Backbone router][backbone-router] on the routes / and /home but have the important distinction of being parse-able at build time so they may be demand loaded with the Circus.loader and integrated into the server routing tables for push state and SSJS support.

This does not necessarily need to be a Backbone router, and can be anything as long as the first parameter is an object with the field routes who's keys define routes in a manner that can be consumed by Circus.loader.

Loaders

Loaders serve as entry points into routers. They will demand load a given router and it's dependencies in response to the current route on the page.

Circus.loader([
  './home',
  './items'
]);

Will generate two different chunks, one for the home router and one for the items route.

Generally a loader is used for simple bootstrapping of an application, along with core libraries.

If two parameters are passed, the first paramter is passed to the loader runtime and maybe used as needed for initialization.

Circus.loader({root: '/foo'}, [
  './home',
  './items'
]);

Would pass the object containing root to the generated module json at runtime.

Generated Code

The loader will generate a JavaScript construct similar to the following:

Circus.loader(__webpack_requre__, moduleJSON);

and Circus.router calls are not modified at build time. Implementors are expected to provide their own implementations of these methods that integrates with their framework of choice.

For those who wish to use a different root object, the Circus name may be changed by passing a circusNamespace option to the Circus.config compiler method.