Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add documentation for using browserify transforms #45

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ node --v8-options | grep harmony
#### Chrome >= 28 ####
Turn on an experimental flag. Look for "Enable Experimental JavaScript" at [chrome://flags](chrome://flags).

#### Other ####
#### Transpilation ####

Use one of the js-to-js compilers:
- [Facebook Regenerator](http://facebook.github.io/regenerator/).
- [Facebook Regenerator](http://facebook.github.io/regenerator/)
- [Google Closure Compiler](https://developers.google.com/closure/compiler/) with `--language_in ECMASCRIPT6 --language_out ECMASCRIPT3` flags.
- [Google Traceur](https://github.com/google/traceur-compiler).
- [Babel](babeljs.io).

Or, if you use Python's Twisted:
https://github.com/ubolonton/twisted-csp
Expand All @@ -85,6 +86,15 @@ npm install js-csp
bower install js-csp
```

## Using transforms with Browserify ##

When using a transform with Browserify, it doesn't apply to the dependencies in the `node_modules` folder. In case you are using js-csp in an environment without ES6 generators, you would need to use one of the transpilers mentioned above to transpile the code.

Since js-csp doesn't make any assumtion about the environment, there is no particular configuration in the `package.json` file for browserify. You can work around it in one of two ways:

- Apply transforms globally: This will apply a transform to all your dependencies. While and ES6 to ES5 transpiler may work fine on all your dependencies, there might be strange errors. It will also be slow.
- You can use [Viralify](https://www.npmjs.com/package/viralify). Viralify is a simple command line tool that lets you add transforms to package.json file of particular dependencies. For example, if you wanted to use the Babelify transform for js-csp you could run this command in the root of your project: `$ viralify . -p js-csp -t babelify`

## TODO ##

- Multiplexing, mixing, publishing/subscribing.
Expand Down