UNPKG

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