UNPKG

785 BJavaScriptView Raw
1import path from 'path';
2import {SimpleCompilerBase} from './compiler-base';
3import mimeTypes from '@paulcbetts/mime-types';
4
5const inputMimeTypes = ['text/plain', 'image/svg+xml'];
6
7
8/**
9 * @access private
10 *
11 * This class is used for binary files and other files that should end up in
12 * your cache directory, but aren't actually compiled
13 */
14export default class PassthroughCompiler extends SimpleCompilerBase {
15 constructor() {
16 super();
17 }
18
19 static getInputMimeTypes() {
20 return inputMimeTypes;
21 }
22
23 compileSync(sourceCode, filePath) {
24 return {
25 code: sourceCode,
26 mimeType: mimeTypes.lookup(filePath)
27 };
28 }
29
30 getCompilerVersion() {
31 return require(path.join(__dirname, '..', 'package.json')).version;
32 }
33}