# babel-plugin-transform-cjs-system-wrapper

> Wraps CommonJS scripts into System.registerDynamic(...

Latest version **0.6.2** (published 2017-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-cjs-system-wrapper
pnpm add babel-plugin-transform-cjs-system-wrapper
yarn add babel-plugin-transform-cjs-system-wrapper
bun add babel-plugin-transform-cjs-system-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.6.2 |
| Published | 2017-05-30 |
| First published | 2016-08-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Jochen Rauschenbusch |
| Maintainers | guybedford, jrauschenbusch |
| Keywords | babel, plugin, systemjs, babel-plugin |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-cjs-system-wrapper
- Repository: https://github.com/jrauschenbusch/babel-plugin-transform-cjs-system-wrapper
- Homepage: https://github.com/jrauschenbusch/babel-plugin-transform-cjs-system-wrapper#readme
- Issues: https://github.com/jrauschenbusch/babel-plugin-transform-cjs-system-wrapper/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-cjs-system-wrapper

## Dependencies (1)

- [babel-template](https://npm.io/package/babel-template.md) ^6.9.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.6.2 (latest) — 2017-05-30
- 0.6.1 — 2017-05-30
- 0.6.0 — 2017-02-01
- 0.5.0 — 2017-01-24
- 0.4.0 — 2017-01-23
- 0.3.0 — 2016-12-07
- 0.2.1 — 2016-08-25
- 0.2.0 — 2016-08-24
- 0.0.3 — 2016-08-03
- 0.0.2 — 2016-08-03

## README

# babel-plugin-transform-cjs-system-wrapper

Wraps CommonJS scripts into `System.registerDynamic(...`

## Example

**In**

```js
'use strict';

var foo = require('foo/');
```

**Babel Options**
```js
{
  moduleId: 'foobar'
  plugins: [
    ['transform-cjs-system-wrapper', {
      deps: ['bar'],
      globals: {
        f: foo
      }
    }]
  ]
}
```

**Out**

```js
System.registerDynamic('foobar', ['bar'], true, function ($__require, exports, module) {
  'use strict';

  var f = $__require('foo');
  var global = this,
      GLOBAL = this;
  var foo = $__require('foo');
});
```

## Installation

```sh
$ npm install babel-plugin-transform-cjs-system-wrapper
```

## Usage

### Via `.babelrc`

**.babelrc**

```json
{
  "moduleId": "foobar",
  "plugins": [
    ["transform-cjs-system-wrapper", {
      "systemGlobal": "SystemJS",
      "path": "/path/to/foobar",
      "optimize": true,
      "static": true,
      "deps": ["bar"],
      "esModule": true,
      "globals": {
        "f": "foo"
      }
    }]
  ]
}
```

### Via CLI

```sh
$ babel --plugins transform-cjs-system-wrapper script.js
```

### Via Node API (Recommended)

```javascript
require("babel-core").transform("code", {
  moduleId: 'foobar', // optional (default: '')
  plugins: [
    ["transform-cjs-system-wrapper", {
      requireName: 'require' // (default: 'require')
      systemGlobal: "SystemJS", // optional (default: 'SystemJS')
      path: "/path/to/foobar", // optional (default: '')
      optimize: true, // optional (default: false)
      static: true, // optional (default: false)
      deps: ['bar'], // optional (default: []),
      esModule: true, // optional (default: false)
      map: function(dep) {
        return mappedDep
      }, // (default: identity)
      globals: {  // optional (default: {})
        f: foo
      }
    }]
  ]
});
```

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