diff --git a/packages/wxa-cli/src/resolvers/component/index.js b/packages/wxa-cli/src/resolvers/component/index.js index a6728be2..b8059704 100644 --- a/packages/wxa-cli/src/resolvers/component/index.js +++ b/packages/wxa-cli/src/resolvers/component/index.js @@ -95,7 +95,4 @@ export default class ComponentManager { } }, []); } - - findComponentSource(com, mdl) { - } } diff --git a/packages/wxa-cli/src/resolvers/xml/index.js b/packages/wxa-cli/src/resolvers/xml/index.js index 62822d92..05f4d7f9 100644 --- a/packages/wxa-cli/src/resolvers/xml/index.js +++ b/packages/wxa-cli/src/resolvers/xml/index.js @@ -21,9 +21,11 @@ class XMLManager { parse(mdl) { if (mdl.xml == null) return null; - let libs = this.walkXML(mdl.xml, mdl); + let libs = []; - debug('libs in xml %O %O', mdl.xml, libs); + mdl.xml.forEach((element) => { + libs = libs.concat(this.walkXML(element, mdl)); + }); mdl.code = new Coder().decodeTemplate(domSerializer(mdl.xml, {xmlMode: true})); @@ -31,19 +33,16 @@ class XMLManager { } walkXML(xml, mdl) { - debug('walk xml start %s', xml.nodeType); let libs = []; // ignore comment - if (xml.nodeType === NODE.COMMENT_NODE) return libs; + if (xml.type === 'comment') return libs; - if (xml.nodeType === NODE.ELEMENT_NODE) { - // element p view - debug('xml %O', xml); + if (xml.type === 'tag') { libs = libs.concat(this.walkAttr(xml.attribs, mdl)); } - if (xml.childNodes) { - libs = libs.concat(Array.prototype.slice.call(xml.childNodes).reduce((ret, child)=>{ + if (xml.children) { + libs = libs.concat(Array.prototype.slice.call(xml.children).reduce((ret, child)=>{ return ret.concat(this.walkXML(child, mdl)); }, [])); } diff --git a/packages/wxa-cli/src/schedule.js b/packages/wxa-cli/src/schedule.js index 1e364641..6ff3a37e 100644 --- a/packages/wxa-cli/src/schedule.js +++ b/packages/wxa-cli/src/schedule.js @@ -138,6 +138,8 @@ class Schedule { } async $parse(dep) { + if (dep.color === COLOR.COMPILED) return []; + if (dep.color === COLOR.CHANGED) dep.code = void(0); // calc hash // cause not every module is actually exists, we can not promise all module has hash here. let content = dep.content ? dep.content : readFile(dep.src); @@ -293,26 +295,25 @@ class Schedule { output: new Set([dep.meta.outputPath]), outerDependencies: new Set(), dependency: function(file) { - // let DR = new DependencyResolver(scheduler.wxaConfigs.resolve, scheduler.meta); - // let {source} = DR.resolveDep(file, this); - // debugger; this.outerDependencies.add(file); }, }; - if (this.$indexOfModule.has(dep.src)) { let indexedModule = this.$indexOfModule.get(dep.src); // check hash child.hash = !child.isAbstract && child.content ? getHashWithString(child.content) : getHash(child.src); - if (child.hash !== indexedModule.hash) { - // module changed, clean up mdl. + // module changed: clean up mdl, mark module as changed. + if ( + child.hash !== indexedModule.hash && + indexedModule.color === COLOR.COMPILED + ) { indexedModule.content = child.content; - indexedModule.code = void(0); indexedModule.hash = child.hash; + indexedModule.color = COLOR.CHANGED; } // merge reference, cause the module is parsed @@ -329,7 +330,7 @@ class Schedule { child = indexedModule; } - // debugger; + if (child.color !== COLOR.COMPILED) this.$depPending.push(child); if (child.color === COLOR.INIT) this.$indexOfModule.set(child.src, child);