1 | import CJSImportProcessor from "./CJSImportProcessor";
|
2 | import { RawSourceMap } from "./computeSourceMap";
|
3 | import NameManager from "./NameManager";
|
4 | import { Scope } from "./parser/tokenizer/state";
|
5 | import TokenProcessor from "./TokenProcessor";
|
6 | export declare type Transform = "jsx" | "typescript" | "flow" | "imports" | "react-hot-loader";
|
7 | export interface SourceMapOptions {
|
8 | /**
|
9 | * The name to use in the "file" field of the source map. This should be the name of the compiled
|
10 | * file.
|
11 | */
|
12 | compiledFilename: string;
|
13 | }
|
14 | export interface Options {
|
15 | transforms: Array<Transform>;
|
16 | /**
|
17 | * If specified, function name to use in place of React.createClass when compiling JSX.
|
18 | */
|
19 | jsxPragma?: string;
|
20 | /**
|
21 | * If specified, function name to use in place of React.Fragment when compiling JSX.
|
22 | */
|
23 | jsxFragmentPragma?: string;
|
24 | /**
|
25 | * If true, replicate the import behavior of TypeScript's esModuleInterop: false.
|
26 | */
|
27 | enableLegacyTypeScriptModuleInterop?: boolean;
|
28 | /**
|
29 | * If true, replicate the import behavior Babel 5 and babel-plugin-add-module-exports.
|
30 | */
|
31 | enableLegacyBabel5ModuleInterop?: boolean;
|
32 | /**
|
33 | * If specified, we also return a RawSourceMap object alongside the code. Currently, source maps
|
34 | * simply map each line to the original line without any mappings within lines, since Sucrase
|
35 | * preserves line numbers. filePath must be specified if this option is enabled.
|
36 | */
|
37 | sourceMapOptions?: SourceMapOptions;
|
38 | /**
|
39 | * File path to use in error messages, React display names, and source maps.
|
40 | */
|
41 | filePath?: string;
|
42 | /**
|
43 | * If specified, omit any development-specific code in the output.
|
44 | */
|
45 | production?: boolean;
|
46 | }
|
47 | export interface TransformResult {
|
48 | code: string;
|
49 | sourceMap?: RawSourceMap;
|
50 | }
|
51 | export interface SucraseContext {
|
52 | tokenProcessor: TokenProcessor;
|
53 | scopes: Array<Scope>;
|
54 | nameManager: NameManager;
|
55 | importProcessor: CJSImportProcessor | null;
|
56 | }
|
57 | export declare function getVersion(): string;
|
58 | export declare function transform(code: string, options: Options): TransformResult;
|
59 | /**
|
60 | * Return a string representation of the sucrase tokens, mostly useful for
|
61 | * diagnostic purposes.
|
62 | */
|
63 | export declare function getFormattedTokens(code: string, options: Options): string;
|