# module-wrapper

Latest version **0.0.6** (published 2014-03-03) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install module-wrapper
pnpm add module-wrapper
yarn add module-wrapper
bun add module-wrapper
```

## 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.6 |
| Published | 2014-03-03 |
| First published | 2013-12-07 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | spud |

## Links

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

## Dependencies (4)

- [chai](https://npm.io/package/chai.md) ~1.8.1
- [mocha](https://npm.io/package/mocha.md) ~1.15.1
- [fs-sync](https://npm.io/package/fs-sync.md) ~0.2.4
- [uglify-js](https://npm.io/package/uglify-js.md) ~2.4.6

## Recent versions

- 0.0.6 (latest) — 2014-03-03
- 0.0.5 — 2014-01-23
- 0.0.4 — 2014-01-02
- 0.0.3 — 2013-12-19
- 0.0.2 — 2013-12-09
- 0.0.1 — 2013-12-07

## README

#module-wrapper [![Build Status](https://travis-ci.org/supersheep/module-wrapper.png?branch=master)](https://travis-ci.org/supersheep/module-wrapper)


wrap a commonjs module to module-wrapping/module-transport style

###usage

	var wrapper = require("module-wrapper");

	wrapper.wrap("a.js", {
		id:"a"
	}, function(err, content){
		// use the content
	});

### options

	- id: `id` of the module, it passed will result
	- define: `define` function for your loader, defaults to "define"
	- render: render function accept arguments and output the final code

### default result
	
input.js:

	var b = require("b");
	var c = require("c");

output:

	define(["b", "c"], function() {
	var b = require("b");
	var c = require("c");
	});


### customize your renderer

the `render` function accept an `option` argument which contains fields as below:

	- define: the define function name
	- code: the raw origin code
	- deps: the dependencies of the module
	- id: the identifier of the module

### errors
	
	- SyntaxError: throw when fail to pass module dependencies
	- AreadyWrappedError: throw when module is already wrapped

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