feat: 优化require解析流程 提高命中率
This commit is contained in:
parent
f19975ca5f
commit
648a9808b7
@ -6,7 +6,7 @@
|
|||||||
(function (parent) {
|
(function (parent) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var File = Java.type("java.io.File");
|
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)) {
|
if (_canonical(name)) {
|
||||||
name = _canonical(name);
|
name = _canonical(name);
|
||||||
}
|
}
|
||||||
var temp = [parent].concat(paths);
|
// 解析本地目录
|
||||||
for(var i in temp) {
|
if(name.startsWith('./') || name.startsWith('../')){
|
||||||
var path = temp[i];
|
return resolveAsFile(parent, name) || resolveAsDirectory(parent, name) || undefined;
|
||||||
var result = resolveAsFile(path, name) || resolveAsDirectory(path, name);
|
} else {
|
||||||
if (result) {
|
// 查找可能存在的路径
|
||||||
return result;
|
for(var i in paths) {
|
||||||
|
var path = paths[i];
|
||||||
|
var result = resolveAsFile(path, name) || resolveAsDirectory(path, name);
|
||||||
|
if (result) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
Loading…
Reference in New Issue
Block a user