From f7954881fb1e12ac42c3daf36606a964fb1317db Mon Sep 17 00:00:00 2001 From: houhaoyu Date: Fri, 22 Oct 2021 19:24:05 +0800 Subject: [PATCH] houhaoyu@huawei.com de-duplicate module Signed-off-by: houhaoyu Change-Id: I2b3122383aaf39c14e05c653303d8bfa6f04d557 --- ace-loader/src/module-collection-plugin.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ace-loader/src/module-collection-plugin.js b/ace-loader/src/module-collection-plugin.js index 1d879f9..4f237dc 100644 --- a/ace-loader/src/module-collection-plugin.js +++ b/ace-loader/src/module-collection-plugin.js @@ -33,7 +33,7 @@ class ModuleCollectionPlugin { }, (assets, back) => { const keys = Object.keys(assets); - const moduleList = []; + let moduleList = new Set(); keys.forEach(key => { const extName = path.extname(key); if (extName === '.js') { @@ -41,13 +41,14 @@ class ModuleCollectionPlugin { const moduleName = source.match(moduleReg); if (moduleName) { moduleName.forEach(function(item) { - moduleList.push(item.replace('@', '')); + moduleList.add(item.replace('@', '')); }); } } }); + const moduleCollection = Array.from(moduleList); compilation.assets['./module_collection.txt'] = - new RawSource(moduleList.length === 0 ? 'NULL' : moduleList.join(',')); + new RawSource(moduleCollection.length === 0 ? 'NULL' : moduleCollection.join(',')); back && back(); }, ); -- Gitee