mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-20 00:54:09 -04:00
+36
-8
@@ -58,6 +58,7 @@ function initProjectConfig(projectConfig) {
|
||||
process.env.aceSuperVisualPath
|
||||
projectConfig.hashProjectPath = projectConfig.hashProjectPath ||
|
||||
hashProjectPath(projectConfig.projectPath)
|
||||
projectConfig.aceBuildJson = projectConfig.aceBuildJson || process.env.aceBuildJson;
|
||||
}
|
||||
|
||||
function loadEntryObj(projectConfig) {
|
||||
@@ -226,19 +227,46 @@ function setEntrance(abilityConfig, abilityPages) {
|
||||
}
|
||||
|
||||
function loadWorker(projectConfig) {
|
||||
const workerPath = path.resolve(projectConfig.projectPath, WORKERS_DIR);
|
||||
if (fs.existsSync(workerPath)) {
|
||||
const workerFiles = [];
|
||||
readFile(workerPath, workerFiles);
|
||||
workerFiles.forEach((item) => {
|
||||
if (/\.(ts|js)$/.test(item)) {
|
||||
const relativePath = path.relative(workerPath, item).replace(/\.(ts|js)$/, '');
|
||||
projectConfig.entryObj[`./${WORKERS_DIR}/` + relativePath] = item;
|
||||
if (validateWorkOption()) {
|
||||
const workerConfig = JSON.parse(fs.readFileSync(projectConfig.aceBuildJson).toString());
|
||||
workerConfig.workers.forEach(worker => {
|
||||
if (!/\.(ts|js)$/.test(worker)) {
|
||||
worker += '.ts';
|
||||
}
|
||||
const relativePath = path.relative(projectConfig.projectPath, worker);
|
||||
if (filterWorker(relativePath)) {
|
||||
projectConfig.entryObj[relativePath.replace(/\.(ts|js)$/,'')] = worker;
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const workerPath = path.resolve(projectConfig.projectPath, WORKERS_DIR);
|
||||
if (fs.existsSync(workerPath)) {
|
||||
const workerFiles = [];
|
||||
readFile(workerPath, workerFiles);
|
||||
workerFiles.forEach((item) => {
|
||||
if (/\.(ts|js)$/.test(item)) {
|
||||
const relativePath = path.relative(workerPath, item).replace(/\.(ts|js)$/, '');
|
||||
projectConfig.entryObj[`./${WORKERS_DIR}/` + relativePath] = item;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateWorkOption() {
|
||||
if (projectConfig.aceBuildJson && fs.existsSync(projectConfig.aceBuildJson)) {
|
||||
const workerConfig = JSON.parse(fs.readFileSync(projectConfig.aceBuildJson).toString());
|
||||
if(workerConfig.workers) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function filterWorker(workerPath) {
|
||||
return /\.(ts|js)$/.test(workerPath) && !/^\.\./.test(workerPath);
|
||||
}
|
||||
|
||||
;(function initSystemResource() {
|
||||
const sysResourcePath = path.resolve('./sysResource.js');
|
||||
if (fs.existsSync(sysResourcePath)) {
|
||||
|
||||
@@ -75,7 +75,6 @@ export class ResultStates {
|
||||
private modulePaths: Set<string> = new Set([]);
|
||||
|
||||
public apply(compiler: Compiler): void {
|
||||
|
||||
compiler.hooks.compilation.tap('SourcemapFixer', compilation => {
|
||||
compilation.hooks.afterProcessAssets.tap('SourcemapFixer', assets => {
|
||||
Reflect.ownKeys(assets).forEach(key => {
|
||||
@@ -110,14 +109,14 @@ export class ResultStates {
|
||||
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
||||
},
|
||||
(assets) => {
|
||||
const GLOBAL_COMMON_MODULE_CACHE = `
|
||||
const GLOBAL_COMMON_MODULE_CACHE = `
|
||||
globalThis["__common_module_cache__${projectConfig.hashProjectPath}"] =` +
|
||||
` globalThis["__common_module_cache__${projectConfig.hashProjectPath}"] || {};
|
||||
globalThis["webpackChunk${projectConfig.hashProjectPath}"].forEach((item)=> {
|
||||
Object.keys(item[1]).forEach((element) => {
|
||||
globalThis["__common_module_cache__${projectConfig.hashProjectPath}"][element] = null;
|
||||
})
|
||||
});`
|
||||
});`;
|
||||
|
||||
if (assets['commons.js']) {
|
||||
assets['commons.js'] = new CachedSource(
|
||||
|
||||
Reference in New Issue
Block a user