modify node build module

This commit is contained in:
kekee000 2015-04-17 10:49:21 +08:00
parent cbdc69f983
commit f105736611
3 changed files with 14 additions and 1 deletions

View File

@ -3,4 +3,5 @@
# ttf 模块node端组件导出程序
edp build --config ./edp-build-config-node.js --force
echo "asset path../fonteditor-ttf/lib"

View File

@ -38,6 +38,7 @@ exports.getProcessors = function () {
'common/DataStore.js',
'common/observable.js',
'common/promise.js',
'common/getPixelRatio.js',
'editor/**',
'fonteditor/**',
'render/**',

View File

@ -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 + '\')';