From c77105574c3ee200b1809dd32752dff14f18c351 Mon Sep 17 00:00:00 2001 From: wuhaidong <642168403@qq.com> Date: Thu, 23 Apr 2015 10:04:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8alias?= =?UTF-8?q?=E6=97=B6=E4=BE=9D=E8=B5=96=E6=8F=90=E5=8F=96=E4=B8=8D=E5=85=A8?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用alias时候不会递归的提取依赖 --- tasks/lib/script.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tasks/lib/script.js b/tasks/lib/script.js index 2d848fc..bfdfba4 100644 --- a/tasks/lib/script.js +++ b/tasks/lib/script.js @@ -232,7 +232,7 @@ exports.init = function(grunt) { }); var deps = parsed.map(function(meta) { return meta.dependencies.map(function(id) { - id = iduri.absolute(alias, id); + id = iduri.absolute(alias, iduri.isAlias(options, id) ? iduri.parseAlias(options, id) : id); // won't return if deps were loaded(defined in file) if (!_.contains(ids, id) && !_.contains(ids, id.replace(/\.js$/, ''))) { id = iduri.appendext(id); @@ -247,12 +247,23 @@ exports.init = function(grunt) { } }); }); - return [{ + var resultDeps = [{ id: alias, path: file.path, hash: file.hash, contents: file.contents }].concat(deps); + + //递归提取子依赖 + deps.map(function(item) { + item.map(function(meta) { + if (meta) { + resultDeps = resultDeps.concat(parseFileDependencies(meta.path)); + } + }); + }); + + return resultDeps; } function getFileInfo(path){ From 28758c3db040195bb321cbcd91df01654856f83b Mon Sep 17 00:00:00 2001 From: wuhaidong <642168403@qq.com> Date: Thu, 23 Apr 2015 10:09:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=BF=E7=94=A8alias?= =?UTF-8?q?=E6=97=B6=E4=BE=9D=E8=B5=96=E6=8F=90=E5=8F=96=E4=B8=8D=E5=85=A8?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用alias只提取一层依赖,没有递归的提取相关子依赖 --- tasks/lib/script.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tasks/lib/script.js b/tasks/lib/script.js index bfdfba4..98e9c6b 100644 --- a/tasks/lib/script.js +++ b/tasks/lib/script.js @@ -253,8 +253,7 @@ exports.init = function(grunt) { hash: file.hash, contents: file.contents }].concat(deps); - - //递归提取子依赖 + deps.map(function(item) { item.map(function(meta) { if (meta) {