Created
August 28, 2015 19:48
-
-
Save jed/72fd006b9c800c66c3fd to your computer and use it in GitHub Desktop.
Using iojs on AWS Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {join} from "path" | |
import browserify from "browserify" | |
import babelify from "babelify" | |
import archiver from "archiver" | |
let opts = { | |
standalone: "code", | |
// these are the API equivalent of --node | |
// https://github.com/substack/node-browserify/blob/master/bin/args.js#L67-L78 | |
bare: true, | |
browserField: false, | |
builtins: false, | |
commondir: false, | |
detectGlobals: false, | |
igv: "__filename,__dirname" | |
} | |
let handlerPath = join(__dirname, process.argv[2]) | |
let indexPath = join(__dirname, "index.js") | |
let iojsPath = join(__dirname, "vendor", "iojs") | |
let iojs = createReadStream(iojsPath) | |
let handler = browserify(handlerPath, opts) | |
.transform(babelify) | |
.exclude("aws-sdk") | |
.bundle() | |
let index = browserify(indexPath, opts) | |
.transform(babelify) | |
.exclude("aws-sdk") | |
.bundle() | |
let zip = archiver("zip") | |
.append(iojs, {name: "iojs", mode: 0o755}) | |
.append(handler, {name: "handler.js"}) | |
.append(index, {name: "index.js"}) | |
.finalize() | |
zip.pipe(process.stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ babel-node bundle.js my-lambda.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment