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
29 lines (24 loc) · 649 Bytes
/
index.ts
File metadata and controls
29 lines (24 loc) · 649 Bytes
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
import Transpiler, { TranspilerResult } from '..';
import { LoaderContext } from '../../transpiled-module';
/**
* Just fetches a file from the interwebs and converts it to a blob
*
* @class BinaryTranspiler
* @extends {Transpiler}
*/
class BinaryTranspiler extends Transpiler {
constructor() {
super('binary-loader');
}
doTranspilation(
code: string,
loaderContext: LoaderContext
): Promise<TranspilerResult> {
return fetch(code)
.then(res => res.blob())
.then(blob => ({ transpiledCode: blob }));
}
}
const transpiler = new BinaryTranspiler();
export { BinaryTranspiler };
export default transpiler;