From 648a9808b76f3c0a04c9fd8d429e1e368104aa54 Mon Sep 17 00:00:00 2001 From: coding Date: Wed, 11 Oct 2017 18:06:07 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96require=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=B5=81=E7=A8=8B=20=E6=8F=90=E9=AB=98=E5=91=BD?= =?UTF-8?q?=E4=B8=AD=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/core/require.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/resources/core/require.js b/src/main/resources/core/require.js index 26de84d..a6dfdb1 100644 --- a/src/main/resources/core/require.js +++ b/src/main/resources/core/require.js @@ -6,7 +6,7 @@ (function (parent) { 'use strict'; var File = Java.type("java.io.File"); - var paths = ['', parent, parent + '/core', parent + '/kit', parent + '/modules']; + var paths = [parent, '', parent + '/core', parent + '/modules']; /** * 解析模块名称为文件 @@ -21,12 +21,17 @@ if (_canonical(name)) { name = _canonical(name); } - var temp = [parent].concat(paths); - for(var i in temp) { - var path = temp[i]; - var result = resolveAsFile(path, name) || resolveAsDirectory(path, name); - if (result) { - return result; + // 解析本地目录 + if(name.startsWith('./') || name.startsWith('../')){ + return resolveAsFile(parent, name) || resolveAsDirectory(parent, name) || undefined; + } else { + // 查找可能存在的路径 + for(var i in paths) { + var path = paths[i]; + var result = resolveAsFile(path, name) || resolveAsDirectory(path, name); + if (result) { + return result; + } } } return undefined;