From 8e47fcc9a39ee397589b4a72804f87e729a17812 Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Thu, 26 May 2022 21:47:42 +0800 Subject: [PATCH] houhaoyu@huawei.com collect module_collection Signed-off-by: houhaoyu Change-Id: Iadf6e8ffb0df484f709fc491ea5d15e902a53eec --- compiler/src/compile_info.ts | 33 +++++++++++++++++++++++---------- compiler/webpack.config.js | 3 +++ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/compiler/src/compile_info.ts b/compiler/src/compile_info.ts index 4c776d3..24c37a8 100644 --- a/compiler/src/compile_info.ts +++ b/compiler/src/compile_info.ts @@ -203,22 +203,35 @@ export class ResultStates { if (!projectConfig.isPreview) { compiler.hooks.compilation.tap('Collect Components And Modules', compilation => { compilation.hooks.additionalAssets.tapAsync('Collect Components And Modules', callback => { - if (projectConfig.aceSuperVisualPath && fs.existsSync(projectConfig.aceSuperVisualPath)) { - appComponentCollection.clear(); - } - const moduleContent: string = - moduleCollection.size === 0 ? 'NULL' : Array.from(moduleCollection).join(','); - writeFileSync(path.resolve(projectConfig.buildPath, './module_collection.txt'), - moduleContent); - const componentContent: string = Array.from(appComponentCollection).join(','); - writeFileSync(path.resolve(projectConfig.buildPath, './component_collection.txt'), - componentContent); + this.generateCollectionFile(); callback(); }); }); } } + private generateCollectionFile() { + if (projectConfig.aceSuperVisualPath && fs.existsSync(projectConfig.aceSuperVisualPath)) { + appComponentCollection.clear(); + } + if (fs.existsSync(path.resolve(projectConfig.buildPath, './module_collection.txt'))) { + const lastModuleCollection: string = + fs.readFileSync(path.resolve(projectConfig.buildPath, './module_collection.txt')).toString(); + if (lastModuleCollection && lastModuleCollection !== 'NULL') { + lastModuleCollection.split(',').forEach(item => { + moduleCollection.add(item); + }) + } + } + const moduleContent: string = + moduleCollection.size === 0 ? 'NULL' : Array.from(moduleCollection).join(','); + writeFileSync(path.resolve(projectConfig.buildPath, './module_collection.txt'), + moduleContent); + const componentContent: string = Array.from(appComponentCollection).join(','); + writeFileSync(path.resolve(projectConfig.buildPath, './component_collection.txt'), + componentContent); + } + private printDiagnostic(diagnostic: ts.Diagnostic): void { const message: string = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); if (this.validateError(message)) { diff --git a/compiler/webpack.config.js b/compiler/webpack.config.js index 5517ca3..7b1b2fd 100644 --- a/compiler/webpack.config.js +++ b/compiler/webpack.config.js @@ -327,6 +327,9 @@ module.exports = (env, argv) => { const appResourcePath = env.appResource || process.env.appResource; if (appResourcePath) { readAppResource(resources, appResourcePath); + if (fs.existsSync(appResourcePath) && config.cache) { + config.cache.buildDependencies.config.push(appResourcePath) + } } config.output.library = projectConfig.hashProjectPath; return config;