From 1466b6742dbeef4ed7a296b941fdd5749e5fa40b Mon Sep 17 00:00:00 2001 From: lizhouze Date: Tue, 26 Jul 2022 10:24:09 +0800 Subject: [PATCH] lizhouze@huawei.com Signed-off-by: lizhouze --- ace-loader/src/module-collection-plugin.js | 64 ---------------------- ace-loader/webpack.rich.config.js | 2 - 2 files changed, 66 deletions(-) delete mode 100644 ace-loader/src/module-collection-plugin.js diff --git a/ace-loader/src/module-collection-plugin.js b/ace-loader/src/module-collection-plugin.js deleted file mode 100644 index 4ff146e..0000000 --- a/ace-loader/src/module-collection-plugin.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -const path = require('path'); -const fs = require('fs'); -const { Compilation } = require('webpack'); - -import { mkDir } from './util'; - -const moduleReg = /(@ohos|@system)(\.[a-zA-Z0-9]+)+/g; - -class ModuleCollectionPlugin { - constructor() { - } - - apply(compiler) { - compiler.hooks.thisCompilation.tap('rich', (compilation) => { - compilation.hooks.processAssets.tapAsync( - { - name: 'MyPlugin', - stage: Compilation.PROCESS_ASSETS_STAGE_REPOR, - }, - (assets, back) => { - const keys = Object.keys(assets); - let moduleList = new Set(); - keys.forEach(key => { - const extName = path.extname(key); - if (extName === '.js') { - const source = assets[key].source(); - const moduleName = source.match(moduleReg); - if (moduleName) { - moduleName.forEach(function(item) { - moduleList.add(item.replace('@', '')); - }); - } - } - }); - const moduleCollection = Array.from(moduleList); - const moduleContent = moduleCollection.length === 0 ? 'NULL' : moduleCollection.join(','); - if (!fs.existsSync(process.env.buildPath)) { - mkDir(process.env.buildPath); - } - fs.writeFileSync(path.resolve(process.env.buildPath, './module_collection.txt'), - moduleContent); - back && back(); - }, - ); - }); - } -} - -module.exports = ModuleCollectionPlugin; \ No newline at end of file diff --git a/ace-loader/webpack.rich.config.js b/ace-loader/webpack.rich.config.js index a972081..d1c1e59 100644 --- a/ace-loader/webpack.rich.config.js +++ b/ace-loader/webpack.rich.config.js @@ -21,7 +21,6 @@ var ResultStates = require('./lib/compile-plugin') var GenBinPlugin = require('./lib/genBin-plugin') var GenAbcPlugin = require('./lib/genAbc-plugin').GenAbcPlugin var AfterEmitPlugin = require('./lib/cardJson-plugin').AfterEmitPlugin -var ModuleCollectionPlugin = require('./lib/module-collection-plugin') const { PLATFORM }= require('./lib/lite/lite-enum') const util = require('./lib/util') @@ -203,7 +202,6 @@ function setConfigs(env) { } function setArkPlugin(env, workerFile) { - config.plugins.push(new ModuleCollectionPlugin()) if (env.isPreview === "true" || env.compilerType && env.compilerType === 'ark') { let arkDir = path.join(__dirname, 'bin', 'ark'); if (env.arkFrontendDir) {