Skip to content

Commit

Permalink
fix(cli): 修复需要删除的 this.involved
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfunc authored and Gcaufy committed Aug 31, 2019
1 parent bba89de commit dac4bdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/cli/core/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class Compile extends Hook {
if (evt === 'change') {
let buildTask = {
changed: path.resolve(filepath),
partial: false,
partial: true,
files: []
};
this.hookAsyncSeq('before-wepy-watch-file-changed', buildTask).then(task => {
Expand Down
18 changes: 11 additions & 7 deletions packages/cli/core/plugins/compiler/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ exports = module.exports = function () {
// When file changed in --watch model
this.register('before-wepy-watch-file-changed', function beforeWatchFileChanged (buildTask) {
const changedFile = buildTask.changed;
let involvedFile = this.involved[changedFile];
if (typeof involvedFile === 'string' && path.isAbsolute(involvedFile)) {
// clear the file hash, to remove the file cache
this.compiled[involvedFile].hash = '';
}
const isInvolved = this.fileDep.isInvolved(changedFile);
this.fileDep.getSources(changedFile).forEach(depedFile => {
if (path.isAbsolute(depedFile)) {
// clear the file hash, to remove the file cache
this.compiled[depedFile].hash = '';
}
});

if (involvedFile) {
if (isInvolved) {
this.logger.silly('watch', `Watcher triggered by file changes: ${changedFile}`);
const isEntry = (changedFile === this.options.entry);
let ext = path.extname(changedFile);
Expand All @@ -41,7 +43,9 @@ exports = module.exports = function () {
// when .wxs file changed
this.register('wepy-watch-file-changed-wxs', function (buildTask) {
buildTask.files = this.fileDep.getSources(buildTask.changed);
buildTask.partial = !buildTask.files.includes(this.options.entry);
if (buildTask.files.includes(this.options.entry)) {
buildTask.partial = false;
}

return buildTask;
});
Expand Down

0 comments on commit dac4bdc

Please sign in to comment.