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;