forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
53 lines (44 loc) · 1.14 KB
/
index.ts
File metadata and controls
53 lines (44 loc) · 1.14 KB
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
import { SourceMap } from './utils/get-source-map';
import { LoaderContext } from '../transpiled-module';
import Manager from '../manager';
export interface TranspilerResult {
transpiledCode: any;
ast?: Object;
sourceMap?: SourceMap;
}
export default abstract class Transpiler {
cacheable: boolean;
name: string;
HMREnabled: boolean;
constructor(name: string) {
this.cacheable = true;
this.name = name;
this.HMREnabled = true;
}
/* eslint-disable */
initialize() {}
dispose() {}
cleanModule(loaderContext: LoaderContext) {}
abstract doTranspilation(
code: string,
loaderContext: LoaderContext
): Promise<TranspilerResult>;
/* eslint-enable */
transpile(
code: string,
loaderContext: LoaderContext
): Promise<TranspilerResult> {
return this.doTranspilation(code, loaderContext);
}
/**
* Get custom info of the current transpiler, this is open for implementation
* per transpiler
*/
getTranspilerContext(manager: Manager): Promise<object> {
return Promise.resolve({
name: this.name,
HMREnabled: this.HMREnabled,
cacheable: this.cacheable,
});
}
}