# gulp-es6-module-to-closure

> compile ES6 import/export to goog.require/goog.provide

Latest version **1.0.7** (published 2014-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-es6-module-to-closure
pnpm add gulp-es6-module-to-closure
yarn add gulp-es6-module-to-closure
bun add gulp-es6-module-to-closure
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2014-12-16 |
| First published | 2014-12-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Yosuke Torii |
| Maintainers | jinjor |
| Keywords | gulp, plugin, es6-transpiler, es6, module, transpiler |

## Links

- npm: https://www.npmjs.com/package/gulp-es6-module-to-closure
- Repository: https://github.com/jinjor/gulp-es6-module-to-closure
- Issues: https://github.com/jinjor/gulp-es6-module-to-closure/issues
- npm.io page: https://npm.io/package/gulp-es6-module-to-closure

## Dependencies (7)

- [slash](https://npm.io/package/slash.md) ^1.0.0
- [through2](https://npm.io/package/through2.md) ^0.6.3
- [escodegen](https://npm.io/package/escodegen.md) ^1.4.1
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.1
- [esprima-fb](https://npm.io/package/esprima-fb.md) ^8001.1001.0-dev-harmony-fb
- [es6-promise](https://npm.io/package/es6-promise.md) ^2.0.0
- [js-beautify](https://npm.io/package/js-beautify.md) ^1.5.4

## 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

- 1.0.7 (latest) — 2014-12-16
- 1.0.6 — 2014-12-16
- 1.0.5 — 2014-12-16
- 1.0.4 — 2014-12-10
- 1.0.3 — 2014-12-09
- 1.0.2 — 2014-12-08
- 1.0.1 — 2014-12-07
- 1.0.0 — 2014-12-07
- 0.3.0 — 2014-12-06
- 0.2.0 — 2014-12-05
- 0.1.2 — 2014-12-04
- 0.1.1 — 2014-12-04
- 0.1.0 — 2014-12-04

## README

gulp-es6-module-to-closure
==========================

[![Build Status](https://travis-ci.org/jinjor/gulp-es6-module-to-closure.svg?branch=master)](https://travis-ci.org/jinjor/gulp-es6-module-to-closure)
[![Coverage Status](https://coveralls.io/repos/jinjor/gulp-es6-module-to-closure/badge.png?branch=master)](https://coveralls.io/r/jinjor/gulp-es6-module-to-closure?branch=master)


compile ES6 `import/export` => Google Closure `goog.require/goog.provide`

__Attention:__ For supporting ES6 features, some special rules are introduced.
See examples below, especially if you use translated library from existing code.


## Install

```shell
npm install gulp-es6-module-to-closure --save-dev
```


## Usage

```javascript
var es6ModuleToClosure = require("gulp-es6-module-to-closure");

gulp.src("./src/**/*.js")
  .pipe(es6ModuleToClosure({
    root: 'src',
    namespace: "prefix.name.space"
  }))
  .pipe(gulp.dest("./dist"));
```


## Example

### export

- Compiling `${srcDir}/ns/file-name.js`
  ```javascript
export var foo = 'FOO';
```
  with namespace `com.xxx` will generate
  ```javascript
goog.provide("com.xxx.ns.filename.foo");
goog.scope(function() {
    com.xxx.ns.filename.foo = 'FOO';
});
```
at `${distDir}/ns/file-name.js`.


- Compiling `${srcDir}/ns/file-name.js`
  ```javascript
export default 'FOO';
```
  with namespace `com.xxx` will generate
  ```javascript
goog.provide("com.xxx.ns.filename.default");
goog.scope(function() {
    com.xxx.ns.filename.default = 'FOO';
});
```
  at `${distDir}/ns/file-name.js`.


### import

- Compiling `${srcDir}/ns/app.js`
  ```javascript
import {foo} from './file-name.js';
```
  with namespace `com.xxx` will generate
  ```javascript
goog.require("com.xxx.ns.filename.foo");
goog.scope(function() {
    var foo = com.xxx.ns.filename.foo;
});
```
  at `${distDir}/ns/app.js`.


- Compiling `${srcDir}/ns/app.js`
  ```javascript
import foo from './file-name.js';
```
  with namespace `com.xxx` will generate
  ```javascript
goog.require("com.xxx.ns.filename.default");
goog.scope(function() {
    var foo = com.xxx.ns.filename.default;
});
```
  at `${distDir}/ns/app.js`.


## Supported Syntax

Following table is made from Draft October 14, 2014.

https://people.mozilla.org/~jorendorff/es6-draft.html#sec-static-and-runtme-semantics-module-records

### import

| Syntax                                            | supported |
|:--------------------------------------------------|:---------:|
| import v from "mod";                              |    ✓     |
| import * as ns from "mod";                        |    ✓     |
| import {x} from "mod";                            |    ✓     |
| import {x as v} from "mod"; {x} from "mod";       |    ✓     |

### export

| Syntax                                            | supported |
|:--------------------------------------------------|:---------:|
| export var v;                                     |    ✓     |
| export default function f(){};                    |    ✓     |
| export default function(){};                      |    ✓     |
| export default 42;                                |    ✓     |
| export {x};                                       |    ✓     |
| export {v as x};                                  |    ✓     |
| export {x} from "mod";                            |          |
| export {v as x} from "mod";                       |          |
| export * from "mod";                              |          |

## Migration

### v0.x.x => v1.x.x

Reference from manual code to generated code is changed.

Before:
```
goog.require('name.space.varName');
```
After:
```
goog.require('name.space.fileName.varName');
```

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