-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
176 lines (159 loc) · 5.08 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
declare namespace MeteorCompiler {
export interface ErrorOptions {
message: string;
sourcePath: string;
line: number;
func: string;
}
/**
* JSON or deserialized json sourcemap
*/
export type SourceMap = string | Object;
export interface AddJavaScriptOptions {
sourcePath?: string;
path?: string;
data?: string;
hash?: string;
sourceMap?: SourceMap;
bare?: boolean;
}
export interface FileOptions {
bare?: boolean;
mainModule?: boolean;
lazy?: boolean;
isAsset?: boolean;
}
export class InputFile {
/**
* @summary True if the file can be lazily compiled (deferred using a hash).
*/
public supportsLazyCompilation: boolean;
/**
* @summary Returns the full contents of the file as a buffer.
* @memberof InputFile
* @returns {Buffer}
*/
public getContentsAsBuffer(): Buffer;
/**
* @summary Returns the name of the package or `null` if the file is not in a
* package.
* @memberof InputFile
* @returns {String}
*/
getPackageName(): string;
/**
* @summary Returns the relative path of file to the package or app root
* directory. The returned path always uses forward slashes.
* @memberof InputFile
* @returns {String}
*/
getPathInPackage(): string;
/**
* @summary Returns a hash string for the file that can be used to implement
* caching.
* @memberof InputFile
* @returns {String}
*/
getSourceHash(): string;
/**
* @summary Returns the architecture that is targeted while processing this
* file.
* @memberof InputFile
* @returns {String}
*/
getArch(): string;
/**
* @summary Returns the full contents of the file as a string.
* @memberof InputFile
* @returns {String}
*/
getContentsAsString(): string;
/**
* @summary Returns the filename of the file.
* @memberof InputFile
* @returns {String}
*/
getBasename(): string;
/**
* @summary Returns the directory path relative to the package or app root.
* The returned path always uses forward slashes.
* @memberof InputFile
* @returns {String}
*/
getDirname(): string;
/**
* @summary Returns an object of file options such as those passed as the
* third argument to api.addFiles.
* @memberof InputFile
* @returns {Object}
*/
getFileOptions(): FileOptions;
/**
* @summary Call this method to raise a compilation or linting error for the
* file.
* @param {Object} options
* @param {String} options.message The error message to display.
* @param {String} [options.sourcePath] The path to display in the error message.
* @param {Integer} options.line The line number to display in the error message.
* @param {String} options.func The function name to display in the error message.
* @memberof InputFile
*/
public error(options: ErrorOptions): void;
/**
* @summary Add JavaScript code. The code added will only see the
* namespaces imported by this package as runtime dependencies using
* ['api.use'](#PackageAPI-use). If the file being compiled was added
* with the bare flag, the resulting JavaScript won't be wrapped in a
* closure.
* @param {Object} options
* @param {String} options.path The path at which the JavaScript file
* should be inserted, may not be honored in case of path conflicts.
* @param {String} options.data The code to be added.
* @param {String|Object} options.sourceMap A stringified JSON
* sourcemap, in case the JavaScript file was generated from a
* different file.
* @param {Function} lazyFinalizer Optional function that can be called
* to obtain any remaining options that may be
* expensive to compute, and thus should only be
* computed if/when we are sure this JavaScript will
* be used by the application.
* @memberOf InputFile
* @instance
*/
public addJavaScript(
options: AddJavaScriptOptions,
lazyFinalizer?: () => Partial<AddJavaScriptOptions>
): void;
}
/**
* For the npm babel-meteor wrapper
* https://github.com/meteor/babel/blob/master/options.js
*/
export interface BabelFeatures {
nodeMajorVersion?: number;
modernBrowsers?: boolean;
generateLetDeclarations?: boolean;
jscript?: boolean;
react?: boolean;
inlineNodeEnv?: boolean;
keepFnName?: boolean;
compileForShell?: boolean;
compileModulesOnly?: boolean;
runtime?: boolean;
avoidModernSyntax?: boolean;
enforceStrictMode?: boolean;
dynamicImport?: boolean;
compact?: boolean;
sourceMaps?: boolean;
ast?: boolean;
// Disable .babelrc lookup and processing.
babelrc?: boolean;
// Disable babel.config.js lookup and processing.
configFile?: boolean;
typescript?: boolean;
parserOpts?: any;
}
export abstract class Compiler {
public abstract processFilesForTarget(inputFiles: InputFile[]): void;
}
}