Match-id-ed3ccf5136bb4a98c5b654542c0e591b7e591330

This commit is contained in:
* 2023-09-18 19:57:18 +08:00
parent 8c6d15b7e1
commit 07cf2ba622
9 changed files with 14 additions and 21 deletions

View File

@ -38,7 +38,6 @@ class BasicGenerator extends Generator {
readStream.pipe(writeStream);
readStream.on('error', err => console.error(err));
writeStream.on('error', err => console.error(err));
// writeStream.on('finish', () => console.log(`Copied ${src} to ${dest}`));
}
/**

View File

@ -13,7 +13,6 @@ export default (api: any) => {
api.applyHook({ name: 'beforeCompile', args: state });
state.forEach((s: any) => {
webpack(s.config, (err: any, stats: any) => {
// api.applyHook({ name: 'afterCompile' });
if (err || stats.hasErrors()) {
api.logger.error(`Build failed.err: ${err}, stats:${stats}`);
}

View File

@ -30,7 +30,7 @@ export default (api: API) => {
if (api.userConfig.devBuildConfig.devProxy) {
devServerOptions.onBeforeSetupMiddleware = (devServer: WebpackDevServer) => {
setupProxy(devServer.app, api)
setupProxy(devServer.app, api);
}
}
@ -43,7 +43,7 @@ export default (api: API) => {
api.applyHook({ name: 'afterStartDevServer' });
});
} else {
api.logger.error("Can't find config");
api.logger.error('Can\'t find config');
}
break;
case 'vite':
@ -56,9 +56,10 @@ export default (api: API) => {
server.printUrls();
});
} else {
api.logger.error("Can't find config");
api.logger.error('Can\'t find config');
}
break;
default:
}
},
});

View File

@ -27,6 +27,8 @@ export default (api: API) => {
args._.shift();
const isESM = api.packageJson['type'] === 'module';
await generateJest(args, api.cwd, isESM);
break;
default:
}
},
});

View File

@ -40,7 +40,7 @@ export default class Hub {
pluginPaths: string[] = [];
devProxy: DevProxy | null = null;
logger: Logger;
[key: string]: any;
constructor(opts: HubOpts) {
@ -84,11 +84,11 @@ export default class Hub {
// 获取编译配置
await this.analyzeBuildConfig();
this.setStage(ServiceStage.initPlugins);
this.builtInPlugins = this.getBuiltInPlugins();
await this.pluginManager.register(this.builtInPlugins, this.userConfig.plugins);
this.setStage(ServiceStage.initHooks);
this.pluginManager.initHook();
}
@ -176,13 +176,7 @@ export default class Hub {
}
} else {
this.userConfig.buildConfig.forEach((userBuildConfig) => {
// if (typeof userBuildConfig === 'string') {
// const name = this.getConfigName(userBuildConfig);
// this.buildConfigPath.push({name, path: userBuildConfig});
// }
if (typeof userBuildConfig === 'object') {
// const name = userBuildConfig.name;
// const path = userBuildConfig.path;
this.buildConfigPath.push(userBuildConfig);
}
})

View File

@ -3,7 +3,6 @@ import fs from 'fs';
import { build as esbuild, Plugin } from 'esbuild';
const buildConfig = async (fileName: string, format: 'esm' | 'cjs' = 'esm'): Promise<string> => {
// 外部依赖不构建参与构建,减少执行时间
const pluginExternalDeps: Plugin = {
name: 'plugin-external-deps',

View File

@ -112,7 +112,6 @@ function copyFiles(copyPairs) {
name: 'copy-files',
generateBundle() {
copyPairs.forEach(({ from, to }) => {
console.log(`copy files: ${from}${to}`);
fs.copyFileSync(from, to);
});
},

View File

@ -19,9 +19,9 @@ import { Props } from '../utils/Interface';
function getInitValue(dom: HTMLInputElement, props: Props) {
const { value, defaultValue, checked, defaultChecked } = props;
const defaultValueStr = defaultValue != null ? defaultValue : '';
const initValue = value != null ? value : defaultValueStr;
const initChecked = checked != null ? checked : defaultChecked;
const defaultValueStr = defaultValue !== null && defaultValue !== undefined ? defaultValue : '';
const initValue = value !== null && value !== undefined ? value : defaultValueStr;
const initChecked = checked !== null && checked !== undefined ? checked : defaultChecked;
return { initValue, initChecked };
}

View File

@ -24,7 +24,7 @@ function getInitValue(props: Props) {
let initValue = defaultValue;
// children content存在时会覆盖defaultValue
if (children != null) {
if (children !== null && children !== undefined) {
// 子节点不是纯文本,则取第一个子节点
initValue = children instanceof Array ? children[0] : children;
}
@ -53,7 +53,7 @@ export function updateTextareaValue(dom: HTMLTextAreaElement, props: Props, isIn
} else {
// 获取当前节点的 value 值
let value = props.value;
if (value != null) {
if (value !== null && value !== undefined) {
value = String(value);
// 当且仅当值实际发生变化时才去设置节点的value值
if (dom.value !== value) {