mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 17:51:54 +00:00
feat(cli): add babel loose mode config
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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',
|
||||
|
Reference in New Issue
Block a user