UNPKG

1.75 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
19 export interface BabelifyConstructor {
20 (filename: string, opts: Babelify.BabelifyOptions): Babelify.BabelifyObject;
21 }
22
23 /** 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 */
24 export interface BabelifyOptions extends babel.TransformOptions {
25 /** These are passed to babel.util.canCompile() for each filename
26 * default: null
27 */
28 extensions?: string | string[] | undefined;
29
30 /** if true, a 'sourceFileName' property with a value equal to the current file being transformed is included with the options passed to babel.transform()
31 * default: false
32 */
33 sourceMapsAbsolute?: boolean | undefined;
34 }
35
36 export class BabelifyObject extends stream.Transform {
37 _transform(buf: string | Buffer, encoding: string, callback: () => void): void;
38 _flush(callback: () => void): void;
39 }
40
41 export function configure(opts: Babelify.BabelifyOptions): (filename: string) => Babelify.BabelifyObject;
42}
43
44export = Babelify;
45