UNPKG

1.42 kBTypeScriptView Raw
1/// <reference types="node" />
2
3/** Browserify transform for Babel
4 */
5import stream = require("stream");
6import babel = require("babel-core");
7
8declare function Babelify(filename: string, opts?: Babelify.BabelifyOptions): Babelify.BabelifyObject;
9
10declare namespace Babelify {
11 export interface BabelifyConstructor {
12 (filename: string, opts: Babelify.BabelifyOptions): Babelify.BabelifyObject;
13 }
14
15 /** 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 */
16 export interface BabelifyOptions extends babel.TransformOptions {
17 /** These are passed to babel.util.canCompile() for each filename
18 * default: null
19 */
20 extensions?: string | string[] | undefined;
21
22 /** if true, a 'sourceFileName' property with a value equal to the current file being transformed is included with the options passed to babel.transform()
23 * default: false
24 */
25 sourceMapsAbsolute?: boolean | undefined;
26 }
27
28 export class BabelifyObject extends stream.Transform {
29 _transform(buf: string | Buffer, encoding: string, callback: () => void): void;
30 _flush(callback: () => void): void;
31 }
32
33 export function configure(opts: Babelify.BabelifyOptions): (filename: string) => Babelify.BabelifyObject;
34}
35
36export = Babelify;