fix: 修复在Windows下require插件报错的问题

This commit is contained in:
coding
2017-10-23 13:12:15 +00:00
parent 898872a88f
commit 4cb597e63e
2 changed files with 3 additions and 3 deletions

View File

@ -89,7 +89,7 @@
if (optional.hook) {
origin = optional.hook(origin);
}
base.save(cacheFile, "(function (module, exports, require, __DIR__, __FILE__) {" + origin + "});");
base.save(cacheFile, "(function (module, exports, require, __dirname, __filename) {" + origin + "});");
// 使用 load 可以保留行号和文件名称
var obj = load(cacheFile);
base.delete(cacheFile);
@ -149,7 +149,7 @@
* @private
*/
function _require(name, path, optional) {
var file = resolve(name, path);
var file = _canonical(name) ? name : resolve(name, path);
if (file === undefined) {
log.console("§c模块 §a%s §c加载失败! §4未找到该模块!", name);
return {exports:{}};