From f1057366119ad3fc9264f085d6c7411769d9f7ab Mon Sep 17 00:00:00 2001 From: kekee000 Date: Fri, 17 Apr 2015 10:49:21 +0800 Subject: [PATCH] modify node build module --- build-node.sh | 1 + edp-build-config-node.js | 1 + node/amd2module.js | 13 ++++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/build-node.sh b/build-node.sh index dcbcd5f..2e20ede 100644 --- a/build-node.sh +++ b/build-node.sh @@ -3,4 +3,5 @@ # ttf 模块node端组件导出程序 edp build --config ./edp-build-config-node.js --force + echo "asset path:../fonteditor-ttf/lib" diff --git a/edp-build-config-node.js b/edp-build-config-node.js index 87f923b..215613b 100644 --- a/edp-build-config-node.js +++ b/edp-build-config-node.js @@ -38,6 +38,7 @@ exports.getProcessors = function () { 'common/DataStore.js', 'common/observable.js', 'common/promise.js', + 'common/getPixelRatio.js', 'editor/**', 'fonteditor/**', 'render/**', diff --git a/node/amd2module.js b/node/amd2module.js index 8e3e3cc..5f2b448 100644 --- a/node/amd2module.js +++ b/node/amd2module.js @@ -13,6 +13,13 @@ var REG_TOP_MODULE = /^(:?common|math|graphics|ttf)/; var REG_REQUIRE = /require\(\s*(['"])([^'"]+)\1\s*\)/g; +// dep配置模块,替换成dep的地址 +var REG_DEP_MODULE = /^(:?ClipperLib)/; + +// 相对于lib目录的dep目录 +var DEP_PARH = '../dep/'; + + /** * 获取ast树 * @param {string} code 代码片段 @@ -184,7 +191,11 @@ function replaceDefine(code) { */ function replaceRequire(code, codeDepth) { return code.replace(REG_REQUIRE, function ($0, $1, moduleId) { - if (REG_TOP_MODULE.test(moduleId)) { + + if (REG_DEP_MODULE.test(moduleId)) { + moduleId = codeDepth + DEP_PARH + moduleId; + } + else if (REG_TOP_MODULE.test(moduleId)) { moduleId = codeDepth + moduleId; } return 'require(\'' + moduleId + '\')';