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

geartrain

v0.0.7

Published

Simple Javascript dependency management

Downloads

11

Readme

Geartrain: Simple Javascript Dependency Management

Geartrain is a Javascript dependency management system for people who want the benefits of dependency management but don't want a full-on module system like AMD or CommonJS. To put it another way, it's for people who are okay with using global variables for tying things together. To put it yet another way, it's for people who are okay with going to the public toilet once in a while.

Geartrain is heavily influenced by Sprockets, Bower, and Require.js.

What's in it

In Require.js fashion, Geartrain comes packed with a compiler and an async loader. The compiler takes as argument an entry point .js file, resolves all its dependencies and spits out a concatenated source file with everything your app needs. The async loader is a .js file that you include in your web page. You specify the entry point .js file you want to load using Loader.load('entryPoint.js'), and it will asynchronously resolve and load all the dependencies for you.

Require Directive

To specify a dependency to another Javascript file otherfile.js, use the require directive (in comments)

//= require otherfile

otherfile.js is then looked for in the same directory as the current file. You can use slashes / to walk subdirectories. The require directive syntax is the same as the one used in Sprockets.

Integration with Bower

If you want to use Bower to install packages for you, first install Bower. When installing, instead of using bower install jquery, use

geartrain install jquery

Here is what the install command does: first it uses Bower to install the package; then it writes the dependency map gotten from bower list --map to the file components.json - this is what both the compiler and loader use to resolve dependencies that are provided by Bower. Now you can use a require directive to include jquery

//= require jquery

Using the Compiler

The compiler takes an entry point as parameter, let's say if main.js is the entry point, you would do

geartrain build main

This will appends all dependencies of main.js in the correct order and output the resulting bundled .js file to STDOUT.

Using the Loader

In your html page, first include the geartrain.js - you can find this in the dist folder, which can be re-built by running bin/build.

<script src="geartrain.js"></script>

Then, use Loader.load(entrypoint) to load the entry point file you want.

<script>
Loader.load('main.js');
</script>

It will asynchronously load all its dependencies. Note: you must serve the files over HTTP, local files won't work.

Status

Geartrain is in Proof of Concept (POC) phase at the moment. Probably shouldn't use it for production just yet.

Influences

Weaknesses

  1. Loader does not work when the page is run from the local file system. The loader uses Ajax to retrieve the contents of the .js files, which is subject to the same-origin policy.

License

(The MIT License)

Copyright (c) 2012 Toby Ho <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.