Merge pull request #9761 from TeamworkGuy2/master

[babelify] Added babelify definition
This commit is contained in:
Mohamed Hegazy
2016-06-21 15:00:13 -07:00
committed by GitHub
2 changed files with 69 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
/// <reference path="babelify.d.ts" />
import babelify = require("babelify");
module BabelifyTest {
export function whatDidTheEs6Say(srcPath: string, opts?: babelify.BabelifyOptions) {
opts.extensions = opts.extensions || undefined;
opts.sourceMapsAbsolute = opts.sourceMapsAbsolute || false;
var dst: NodeJS.ReadWriteStream;
babelify(""); // 'opts' are optional
babelify(srcPath, opts).on("error", function (err: any) {
console.error("babelify error: ", err);
});
babelify.configure(opts)(srcPath).pipe(dst);
}
}
export = BabelifyTest;
+46
View File
@@ -0,0 +1,46 @@
// Type definitions for babelify v7.3.0
// Project: https://github.com/babel/babelify
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../babel-core/babel-core.d.ts" />
/** Browserify transform for Babel
*/
declare module 'babelify' {
import stream = require("stream");
import babel = require("babel-core");
function Babelify(filename: string, opts?: Babelify.BabelifyOptions): Babelify.BabelifyObject;
module Babelify {
export interface BabelifyConstructor {
(filename: string, opts: Babelify.BabelifyOptions): Babelify.BabelifyObject;
}
/** In addition to the various purposes documented here, all of the babelify options are passed to babel which passes them on to babel.transform() when each file is transformed */
export interface BabelifyOptions extends babel.TransformOptions {
/** These are passed to babel.util.canCompile() for each filename
* default: null
*/
extensions?: string | string[];
/** if true, a 'sourceFileName' property with a value equal to the current file being transformed is included with the options passed to babel.transform()
* default: false
*/
sourceMapsAbsolute?: boolean;
}
export class BabelifyObject extends stream.Transform {
_transform(buf: string | Buffer, encoding: string, callback: () => void): void;
_flush(callback: () => void): void;
}
export function configure(opts: Babelify.BabelifyOptions): (filename: string) => Babelify.BabelifyObject;
}
export = Babelify;
}