collect module_collection

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: Iadf6e8ffb0df484f709fc491ea5d15e902a53eec
This commit is contained in:
houhaoyu
2022-05-26 21:47:42 +08:00
parent 9f1593a5fc
commit 8e47fcc9a3
2 changed files with 26 additions and 10 deletions
+23 -10
View File
@@ -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)) {
+3
View File
@@ -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;