From 6a69114ba5dff8f994ea3f464b9eac737fa4b1c0 Mon Sep 17 00:00:00 2001 From: zhangrengao Date: Thu, 2 Jun 2022 09:55:31 +0800 Subject: [PATCH] code check Signed-off-by: zhangrengao Change-Id: Id9e95266e0887d669602fb4078c28244f0f16f7b --- compiler/src/gen_abc_plugin.ts | 39 ++++----------------------------- compiler/src/pre_define.ts | 2 +- compiler/src/process_js_ast.ts | 2 +- compiler/src/process_js_file.ts | 2 +- compiler/src/utils.ts | 5 +---- 5 files changed, 8 insertions(+), 42 deletions(-) diff --git a/compiler/src/gen_abc_plugin.ts b/compiler/src/gen_abc_plugin.ts index 9e36e89..8b9d21f 100644 --- a/compiler/src/gen_abc_plugin.ts +++ b/compiler/src/gen_abc_plugin.ts @@ -41,7 +41,7 @@ import { EXTNAME_CJS, EXTNAME_D_TS, EXTNAME_ABC -} from './pre_define' +} from './pre_define'; const firstFileEXT: string = '_.js'; const genAbcScript = 'gen_abc.js'; @@ -59,7 +59,7 @@ interface File { } const intermediateJsBundle: Array = []; let fileterIntermediateJsBundle: Array = []; -const moduleInfos: Array = [];; +const moduleInfos: Array = []; let filterModuleInfos: Array = []; const commonJsModuleInfos: Array = []; const ESMModuleInfos: Array = []; @@ -133,17 +133,6 @@ export class GenAbcPlugin { }); compiler.hooks.compilation.tap('GenAbcPlugin', (compilation) => { - compilation.hooks.afterOptimizeTree.tap('afterOptimizeModules', (chunks, modules) => { - if (projectConfig.compileMode === JSBUNDLE || projectConfig.compileMode === undefined) { - return; - } - modules.forEach(module => { - if (module !== undefined && module.resourceResolveData !== undefined) { - const filePath: string = module.resourceResolveData.path; - } - }); - }); - compilation.hooks.processAssets.tap('processAssets', (assets) => { if (projectConfig.compileMode === JSBUNDLE || projectConfig.compileMode === undefined) { return; @@ -196,14 +185,11 @@ function getEntryInfo(tempFilePath: string, resourceResolveData: any) { return; } - const npmInfoPaths = npmInfoPath.split(NODE_MODULES); - let npmInfo = [NODE_MODULES, npmInfoPaths[npmInfoPaths.length - 1]].join(path.sep); - npmInfo = toUnixPath(npmInfo); let abcFileName = genAbcFileName(tempFilePath); const abcFilePaths = abcFileName.split(NODE_MODULES); abcFileName = [NODE_MODULES, abcFilePaths[abcFilePaths.length - 1]].join(path.sep); abcFileName = toUnixPath(abcFileName); - // let entry = resourceResolveData.descriptionFileData['main'] ?? ""; + const packagePaths = tempFilePath.split(NODE_MODULES); const entryPaths = packagePaths[packagePaths.length - 1].split(packageName); let entry = toUnixPath(entryPaths[entryPaths.length - 1]); @@ -317,7 +303,7 @@ function handleFinishModules(modules, callback) { } function processEntryToGenAbc(entryInfos: Map) { - for (const [key, value] of entryInfos) { + for (const value of entryInfos.values()) { const tempAbcFilePath = toUnixPath(path.resolve(value.npmInfo, ENTRY_TXT)); const buildAbcFilePath = toUnixPath(path.resolve(value.buildPath, ENTRY_TXT)); fs.writeFileSync(tempAbcFilePath, value.entry, 'utf-8'); @@ -475,23 +461,6 @@ function invokeCluterModuleToAbc() { } } -function splitModuleBySize(moduleInfos: Array, groupNumber: number) { - const result = []; - if (moduleInfos.length < groupNumber) { - result.push(moduleInfos); - return result; - } - - for (let i = 0; i < groupNumber; ++i) { - result.push([]); - } - for (let i = 0; i < moduleInfos.length; i++) { - const pos = i % groupNumber; - result[pos].push(moduleInfos[i]); - } - return result; -} - function invokeWorkersToGenAbc() { let param: string = ''; if (isDebug) { diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 5e5c527..1740949 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -251,4 +251,4 @@ export const EXTNAME_TS_MAP: string = '.ts.map'; export const EXTNAME_MJS: string = '.mjs'; export const EXTNAME_CJS: string = '.cjs'; export const EXTNAME_D_TS: string = '.d.ts'; -export const EXTNAME_ABC: string = '.abc'; \ No newline at end of file +export const EXTNAME_ABC: string = '.abc'; diff --git a/compiler/src/process_js_ast.ts b/compiler/src/process_js_ast.ts index ecd3972..acc8219 100644 --- a/compiler/src/process_js_ast.ts +++ b/compiler/src/process_js_ast.ts @@ -17,7 +17,7 @@ import ts from 'typescript'; import { BUILD_ON, ESMODULE - } from './pre_define'; +} from './pre_define'; import { writeFileSyncByNode } from './utils'; import { projectConfig } from '../main'; diff --git a/compiler/src/process_js_file.ts b/compiler/src/process_js_file.ts index 08a7d16..5b8d700 100644 --- a/compiler/src/process_js_file.ts +++ b/compiler/src/process_js_file.ts @@ -3,7 +3,7 @@ import { projectConfig } from '../main'; import { ESMODULE, ARK -} from './pre_define' +} from './pre_define'; module.exports = function processjs2file(source: string): string { if (projectConfig.compileMode === ESMODULE diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index d180aa0..3e07e9a 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -20,10 +20,7 @@ import { projectConfig } from '../main'; import { createHash } from 'crypto'; import { processSystemApi } from './validate_ui_syntax'; import { - ESMODULE, - JSBUNDLE, NODE_MODULES, - ENTRY_TXT, TEMPRARY, MAIN, AUXILIARY, @@ -37,7 +34,7 @@ import { EXTNAME_ETS, EXTNAME_TS_MAP, EXTNAME_JS_MAP -} from './pre_define' +} from './pre_define'; export enum LogType { ERROR = 'ERROR',