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

gravity-js

v0.7.7

Published

A light-weight JS build tool

Downloads

12

Readme

Overview

Often when deploying JS components, you want to compile a multitude of source files down to a single build result. The benefits of doing this include faster performance from the client perspective (due to fewer http hits to load scripts), and potentially simpler integration by the developer integrating your component. Gravity was specifically designed to ease this process.

gravity is a command-line tool that reads gravity.map files.

A gravity.map is a JSON file that can be thought of as a project manifest. In it, you can specify build targets, and the source files that are used to create each target.

	{
		"final.js": [
			"src/1.js",
			"src/2.js",
			...
		]
	}

This tells gravity that you want a build product called final.js, and that it should be the result of compiling various source files (or even other build products) together.

Full documentation of gravity.map syntax can be found in SYNTAX.md.

Installation

Prerequisites:

  • node 0.8 or greater
  • git 1.7 or greater

It is recommended to install for all users:

sudo npm install -g gravity-js

However, if you prefer it can also be installed in your home dir:

npm install gravity-js

Commands

Mac/unix/cygwin users will be able to invoke "gravity" directly. To run the commands in Windows cmd.exe, just prepend "node " to the commands below.

All of the folling commands have <dir> as an optional parameter. If it is not specified, then it is assumed to be the current directory.

gravity list

To see a list of all the build products, where <dir> is the location of your project's directory (ie., wherever the gravity.map file is):

gravity list [<dir>]

gravity serve

During development, you can run gravity as a local server that will perform on-the-fly concatenation of your source.

gravity serve [<dir>] localhost:1337

The server should find an available local port to attach to, and will announce itself:

Gravity server running on http://localhost:1337/

Now you can visit http://localhost:1337/final.js to see the results. Edit a source file, then refresh the page to see the change instantly!

Can also be run as a background process.

gravity serve [<dir>] <host>:<port> &

gravity build

Come build time, run a command like this:

gravity build [<dir>] <outdir>

Gravity will take only your build targets and put them into <outdir>.

gravity pull (a.k.a get)

If you just want to see a specific build target produced and dumped to stdout, you can do this:

gravity pull [<dir>] final.js

Unit Tests

node test.js // Run unit tests silently
node test.js -v // Run unit tests verbosely