mirror of https://github.com/vizality/vizality
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
525 B
24 lines
525 B
const { readFileSync } = require('fs');
|
|
const sucrase = require('sucrase');
|
|
|
|
const Compiler = require('./Compiler');
|
|
|
|
/**
|
|
* TS compiler
|
|
* @extends {Compiler}
|
|
*/
|
|
module.exports = class TS extends Compiler {
|
|
_compile () {
|
|
const ts = readFileSync(this.file, 'utf8');
|
|
return sucrase.transform(ts, {
|
|
transforms: [ 'jsx', 'imports', 'typescript' ],
|
|
enableLegacyBabel5ModuleInterop: true,
|
|
filePath: this.file
|
|
}).code;
|
|
}
|
|
|
|
get _metadata () {
|
|
return `sucrase ${sucrase.getVersion()}`;
|
|
}
|
|
};
|