# sprjs

> A script to glue js files in a sprockets-like manner

Latest version **0.0.1** (published 2015-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install sprjs
pnpm add sprjs
yarn add sprjs
bun add sprjs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2015-04-24 |
| First published | 2015-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | Andrew Pazniak |
| Maintainers | meandre |

## Links

- npm: https://www.npmjs.com/package/sprjs
- npm.io page: https://npm.io/package/sprjs

## Dependencies (3)

- [async](https://npm.io/package/async.md) ^0.9.0
- [lodash](https://npm.io/package/lodash.md) ^3.7.0
- [vinyl-fs](https://npm.io/package/vinyl-fs.md) ^1.0.0

## Recent versions

- 0.0.1 (latest) — 2015-04-24

## README

# SPRjs

**SPRjs** is a fast and reasonably small script which allows to use static comment-based requires in your front-end code.
Typically it's useful when your app is simple and you want to have full control over your build system: no magic involved.
The format and the behavior of require directives are somewhat borrowed from `sprockets`, a well-known `Ruby` library to manage web assets. `sprockets` in fact does much more than just concatenating javascript, while this library focuses on doing one thing (fast).
When a file depends on another file, place a comment at the top saying `//= require ./another/file`.
The path is relative to the file which contains the directive. You can also require globs `//= require ../*` or require
a file own contents before other dependencies by writing `require_self`.
Let's say, you have the following files:

### main.js

    //= require_self
    //= require models/*
    //= require init

    var models = {};
    function main () { /* ... */ }

### init.js

    document.addEventListener('DOMContentLoaded', main);

### models/Post.js

    models.Post = function () { /* ... */ }

The result of calling `sprjs('/path/to/main.js', function callback(err, files) { })` would be invocation of the `callback` function with
`files = ['main.js', 'models/Post.js', 'init.js']`

Please note that `spr` processes directives which are found before any code.

## Usage

1. `npm i sprjs`
2. `var sprjs = require('sprjs'); sprjs('/path/to/main.js', function callback(err, files) { });`

## Gulp

1. Take a look at `gulp-sprjs` if you use `gulp` as your build environment.

---
_Source: https://npm.io/package/sprjs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
