mirror of
https://github.com/openharmony/developtools_ace-ets2bundle.git
synced 2026-07-21 03:55:23 -04:00
output changed files Signed-off-by: houhaoyu <houhaoyu@huawei.com> Change-Id: I3702dbd32f24058238773dfd5895c63555765953
This commit is contained in:
@@ -65,6 +65,8 @@ function initProjectConfig(projectConfig) {
|
||||
projectConfig.cachePath = projectConfig.cachePath || process.env.cachePath ||
|
||||
path.resolve(__dirname, 'node_modules/.cache');
|
||||
projectConfig.aceSoPath = projectConfig.aceSoPath || process.env.aceSoPath;
|
||||
projectConfig.outChangedFileList = (projectConfig.watchMode && projectConfig.watchMode.outChangedFileList) ?
|
||||
projectConfig.watchMode.outChangedFileList : path.join(projectConfig.cachePath, 'changedFileList.json');
|
||||
projectConfig.xtsMode = /ets_loader_ark$/.test(__dirname);
|
||||
}
|
||||
|
||||
|
||||
@@ -223,6 +223,24 @@ export class ResultStates {
|
||||
}
|
||||
});
|
||||
|
||||
compiler.hooks.watchRun.tap('WatchRun', (comp) => {
|
||||
if (process.env.watchMode && projectConfig.outChangedFileList && (comp.modifiedFiles || comp.removedFiles) &&
|
||||
!(comp.modifiedFiles && [...comp.modifiedFiles].length === 1 && [...comp.modifiedFiles][0] == projectConfig.projectPath)) {
|
||||
const filesObj = {
|
||||
modifiedFiles: [...comp.modifiedFiles].filter((file) => {
|
||||
return fs.statSync(file).isFile();
|
||||
}),
|
||||
removedFiles: [...comp.removedFiles]
|
||||
};
|
||||
if (fs.existsSync(path.dirname(projectConfig.outChangedFileList))) {
|
||||
fs.writeFileSync(projectConfig.outChangedFileList, JSON.stringify(filesObj));
|
||||
} else {
|
||||
fs.mkdirSync(path.dirname(projectConfig.outChangedFileList));
|
||||
fs.writeFileSync(projectConfig.outChangedFileList, JSON.stringify(filesObj));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
compiler.hooks.done.tap('Result States', (stats: Stats) => {
|
||||
if (projectConfig.isPreview && projectConfig.aceSoPath &&
|
||||
useOSFiles && useOSFiles.size > 0) {
|
||||
|
||||
@@ -180,7 +180,7 @@ export class GenAbcPlugin {
|
||||
|
||||
function clearGlobalInfo() {
|
||||
// fix bug of multi trigger
|
||||
if (!projectConfig.isPreview) {
|
||||
if (!process.env.watchMode) {
|
||||
intermediateJsBundle = [];
|
||||
moduleInfos = [];
|
||||
}
|
||||
@@ -494,7 +494,7 @@ function invokeCluterModuleToAbc(): void {
|
||||
if (count_ === totalWorkerNumber) {
|
||||
writeModuleHashJson();
|
||||
clearGlobalInfo();
|
||||
if (projectConfig.isPreview) {
|
||||
if (process.env.watchMode) {
|
||||
console.info(blue, 'COMPILE RESULT:SUCCESS ', reset);
|
||||
}
|
||||
}
|
||||
@@ -628,7 +628,7 @@ function invokeWorkersToGenAbc(): void {
|
||||
if (count_ === workerNumber) {
|
||||
writeHashJson();
|
||||
clearGlobalInfo();
|
||||
if (projectConfig.isPreview) {
|
||||
if (process.env.watchMode) {
|
||||
console.info(red, 'COMPILE RESULT:SUCCESS ', reset);
|
||||
}
|
||||
}
|
||||
@@ -733,7 +733,7 @@ function writeModuleHashJson(): void {
|
||||
return;
|
||||
}
|
||||
// fix bug of multi trigger
|
||||
if (!projectConfig.isPreview || delayCount < 1) {
|
||||
if (!process.env.watchMode || delayCount < 1) {
|
||||
fs.writeFileSync(hashFilePath, JSON.stringify(moduleHashJsonObject));
|
||||
}
|
||||
}
|
||||
@@ -778,7 +778,7 @@ function filterIntermediateJsBundleByHashJson(buildPath: string, inputPaths: Fil
|
||||
if (jsonObject[input] === hashInputContentData && jsonObject[abcPath] === hashAbcContentData) {
|
||||
updateJsonObject[input] = hashInputContentData;
|
||||
updateJsonObject[abcPath] = hashAbcContentData;
|
||||
if (!projectConfig.isPreview) {
|
||||
if (!process.env.watchMode) {
|
||||
fs.unlinkSync(input);
|
||||
}
|
||||
} else {
|
||||
@@ -806,7 +806,7 @@ function writeHashJson(): void {
|
||||
const hashAbcContentData: any = toHashData(abcPath);
|
||||
hashJsonObject[input] = hashInputContentData;
|
||||
hashJsonObject[abcPath] = hashAbcContentData;
|
||||
if (!projectConfig.isPreview) {
|
||||
if (!process.env.watchMode) {
|
||||
fs.unlinkSync(input);
|
||||
}
|
||||
}
|
||||
@@ -815,7 +815,7 @@ function writeHashJson(): void {
|
||||
return;
|
||||
}
|
||||
// fix bug of multi trigger
|
||||
if (!projectConfig.isPreview || delayCount < 1) {
|
||||
if (!process.env.watchMode || delayCount < 1) {
|
||||
fs.writeFileSync(hashFilePath, JSON.stringify(hashJsonObject));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP
|
||||
if (ts.isExportDeclaration(node) && node.exportClause &&
|
||||
ts.isNamedExports(node.exportClause) && node.exportClause.elements) {
|
||||
node.exportClause.elements.forEach(item => {
|
||||
if (projectConfig.isPreview) {
|
||||
if (process.env.watchMode) {
|
||||
exportCollection.add((item.propertyName ? item.propertyName : item.name).escapedText.toString());
|
||||
}
|
||||
if (item.name && ts.isIdentifier(item.name)) {
|
||||
@@ -225,7 +225,7 @@ function visitAllNode(node: ts.Node, sourceFile: ts.SourceFile, defaultNameFromP
|
||||
}
|
||||
if (ts.isExportDeclaration(node) && node.moduleSpecifier &&
|
||||
ts.isStringLiteral(node.moduleSpecifier)) {
|
||||
if (projectConfig.isPreview && node.exportClause && ts.isNamedExports(node.exportClause) &&
|
||||
if (process.env.watchMode && node.exportClause && ts.isNamedExports(node.exportClause) &&
|
||||
node.exportClause.elements) {
|
||||
node.exportClause.elements.forEach(item => {
|
||||
exportCollection.add((item.propertyName ? item.propertyName : item.name).escapedText.toString());
|
||||
@@ -293,7 +293,7 @@ function collectSpecialFunctionNode(node: ts.FunctionDeclaration, asNameFromPare
|
||||
function isExportEntry(node: ts.ClassDeclaration, log: LogInfo[], entryCollection: Set<string>,
|
||||
exportCollection: Set<string>, defaultCollection: Set<string>, fileResolvePath: string,
|
||||
sourceFile: ts.SourceFile): void {
|
||||
if (projectConfig.isPreview && node && node.decorators) {
|
||||
if (process.env.watchMode && node && node.decorators) {
|
||||
let existExport: boolean = false;
|
||||
let existEntry: boolean = false;
|
||||
if (node.modifiers) {
|
||||
|
||||
@@ -198,6 +198,9 @@ function setProjectConfig(envArgs) {
|
||||
if (envArgs.cachePath) {
|
||||
projectConfig.cachePath = envArgs.cachePath;
|
||||
}
|
||||
if (envArgs.watchMode) {
|
||||
projectConfig.watchMode = envArgs.watchMode;
|
||||
}
|
||||
}
|
||||
|
||||
function setReleaseConfig(config) {
|
||||
|
||||
Reference in New Issue
Block a user