feat(cli): add babel loose mode config

This commit is contained in:
chenjiahan
2020-12-04 14:12:22 +08:00
parent 52384aba1e
commit be87fac7b6
6 changed files with 15 additions and 5 deletions

View File

@@ -24,6 +24,7 @@ import {
isTestDir,
setNodeEnv,
setModuleEnv,
setBuildTarget,
} from '../common';
async function compileFile(filePath: string) {
@@ -64,12 +65,14 @@ async function compileDir(dir: string) {
async function buildEs() {
setModuleEnv('esmodule');
setBuildTarget('package');
await copy(SRC_DIR, ES_DIR);
await compileDir(ES_DIR);
}
async function buildLib() {
setModuleEnv('commonjs');
setBuildTarget('package');
await copy(SRC_DIR, LIB_DIR);
await compileDir(LIB_DIR);
}

View File

@@ -1,6 +1,10 @@
import { ConfigAPI } from '@babel/core';
module.exports = function (api?: ConfigAPI) {
type PresetOption = {
loose?: boolean;
};
module.exports = function (api?: ConfigAPI, options: PresetOption = {}) {
if (api) {
api.cache.never();
}
@@ -15,6 +19,7 @@ module.exports = function (api?: ConfigAPI) {
'@babel/preset-env',
{
modules: useESModules ? false : 'commonjs',
loose: options.loose,
},
],
'@babel/preset-typescript',