mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-21 03:55:23 -04:00
!1019 Fix cachePath is undefined
Merge pull request !1019 from zrg/jsbundle_unix_beta
This commit is contained in:
@@ -137,6 +137,10 @@ export class GenAbcPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
if (projectConfig.compileMode === ESMODULE) {
|
||||
removeDir(projectConfig.nodeModulesPath);
|
||||
}
|
||||
|
||||
compiler.hooks.compilation.tap('GenAbcPlugin', (compilation) => {
|
||||
if (projectConfig.compileMode === JSBUNDLE || projectConfig.compileMode === undefined) {
|
||||
return;
|
||||
@@ -162,7 +166,6 @@ export class GenAbcPlugin {
|
||||
if (projectConfig.compileMode === ESMODULE) {
|
||||
return;
|
||||
}
|
||||
removeDir(output);
|
||||
Object.keys(compilation.assets).forEach(key => {
|
||||
// choose *.js
|
||||
if (output && path.extname(key) === EXTNAME_JS) {
|
||||
@@ -365,6 +368,8 @@ function writeFileSync(inputString: string, output: string, jsBundleFile: string
|
||||
fs.writeFileSync(cacheOutputPath, inputString);
|
||||
if (fs.existsSync(cacheOutputPath)) {
|
||||
const fileSize: any = fs.statSync(cacheOutputPath).size;
|
||||
output = toUnixPath(output);
|
||||
cacheOutputPath = toUnixPath(cacheOutputPath);
|
||||
intermediateJsBundle.push({path: output, size: fileSize, cacheOutputPath: cacheOutputPath});
|
||||
} else {
|
||||
logger.error(red, `ETS:ERROR Failed to convert file ${jsBundleFile} to bin. ${output} is lost`, reset);
|
||||
@@ -418,8 +423,6 @@ function splitJsBundlesBySize(bundleArray: Array<File>, groupNumber: number): an
|
||||
}
|
||||
|
||||
function invokeWorkersModuleToGenAbc(moduleInfos: Array<ModuleInfo>): void {
|
||||
removeDir(buildPathInfo);
|
||||
removeDir(projectConfig.nodeModulesPath);
|
||||
filterIntermediateModuleByHashJson(buildPathInfo, moduleInfos);
|
||||
filterModuleInfos.forEach(moduleInfo => {
|
||||
if (moduleInfo.isCommonJs) {
|
||||
|
||||
@@ -17,6 +17,7 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const CopyPlugin = require('copy-webpack-plugin');
|
||||
const Webpack = require('webpack');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const { GenAbcPlugin } = require('./lib/gen_abc_plugin');
|
||||
const { OHMResolverPlugin } = require('./lib/resolve_ohm_url');
|
||||
const buildPipeServer = require('./server/build_pipe_server');
|
||||
@@ -338,6 +339,25 @@ function setGenAbcPlugin(env, config) {
|
||||
}
|
||||
}
|
||||
|
||||
function setCleanWebpackPlugin(workerFile, config) {
|
||||
let cleanPath = [];
|
||||
cleanPath.push(projectConfig.buildPath);
|
||||
if (workerFile) {
|
||||
let workerFilesPath = Object.keys(workerFile);
|
||||
for (let workerFilePath of workerFilesPath) {
|
||||
cleanPath.push(path.join(projectConfig.buildPath, workerFilePath, '..'));
|
||||
}
|
||||
}
|
||||
|
||||
config.plugins.push(
|
||||
new CleanWebpackPlugin({
|
||||
dry: false,
|
||||
dangerouslyAllowCleanPatternsOutsideProject: true,
|
||||
cleanOnceBeforeBuildPatterns: cleanPath
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = (env, argv) => {
|
||||
const config = {};
|
||||
setProjectConfig(env);
|
||||
@@ -348,6 +368,7 @@ module.exports = (env, argv) => {
|
||||
const workerFile = readWorkerFile();
|
||||
setOptimizationConfig(config, workerFile);
|
||||
setCopyPluginConfig(config);
|
||||
setCleanWebpackPlugin(workerFile, config);
|
||||
|
||||
if (env.isPreview !== "true") {
|
||||
loadWorker(projectConfig, workerFile);
|
||||
|
||||
Reference in New Issue
Block a user