mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 03:11:15 +00:00
21 lines
561 B
TypeScript
21 lines
561 B
TypeScript
// @ts-ignore
|
|
import { transformFileAsync } from '@babel/core';
|
|
import { removeSync, outputFileSync } from 'fs-extra';
|
|
import { replaceExt } from '../common';
|
|
|
|
export function compileJs(filePath: string): Promise<undefined> {
|
|
return new Promise((resolve, reject) => {
|
|
transformFileAsync(filePath)
|
|
.then(result => {
|
|
if (result) {
|
|
const jsFilePath = replaceExt(filePath, '.js');
|
|
|
|
removeSync(filePath);
|
|
outputFileSync(jsFilePath, result.code);
|
|
resolve();
|
|
}
|
|
})
|
|
.catch(reject);
|
|
});
|
|
}
|