Comparing version 0.0.6 to 0.0.7
@@ -10,3 +10,3 @@ { | ||
"description": "beef - brwoser end equals framework", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"repository": { | ||
@@ -31,4 +31,4 @@ "type": "git", | ||
"scripts": { | ||
"test": "node test/test.js" | ||
"test": "jasmine-node ./test" | ||
} | ||
} |
@@ -32,3 +32,24 @@ beef -- 牛排 | ||
``` | ||
### 支持多模块配置 | ||
- v0.0.7开始 | ||
```js | ||
// 配置第一次 | ||
require.config({ | ||
name: 'source', | ||
baseUrl: './source', | ||
packages: { | ||
'resource': './resource' | ||
} | ||
}); | ||
// 配置第二次 | ||
require.config({ | ||
name: 'admin', | ||
baseUrl: './admin', | ||
packages: { | ||
'public': './public' | ||
} | ||
}); | ||
``` | ||
@@ -35,0 +56,0 @@ ## 使用方法 |
@@ -5,18 +5,39 @@ var path = require('path'); | ||
module.exports = { | ||
config: function(option) { | ||
if (option.baseUrl) { | ||
root = path.resolve(root, option.baseUrl) | ||
config: function (option) { | ||
var baseUrl = option.baseUrl; | ||
if (baseUrl) { | ||
baseUrl = path.resolve(process.cwd(), baseUrl); | ||
root = baseUrl; | ||
if (option.name) { | ||
packages[option.name] = baseUrl; | ||
} | ||
} else { | ||
baseUrl = root; | ||
} | ||
if (option.packages) { | ||
packages = option.packages; | ||
var pkgs = option.packages; | ||
for (var item in packages) { | ||
packages[item] = path.resolve(root, packages[item]); | ||
for (var item in pkgs) { | ||
if (packages.hasOwnProperty(item)) { | ||
throw Error('packages aready existed'); | ||
} else { | ||
packages[item] = path.resolve(baseUrl, pkgs[item]); | ||
} | ||
} | ||
} | ||
}, | ||
resolve: function(relativeId, module) { | ||
clear: function (pkg) { | ||
if (pkg === true) { | ||
packages = {}; | ||
return; | ||
} | ||
// 单独删除一个包 | ||
if (pkg && packages.hasOwnProperty(pkg)) { | ||
delete packages.pkg; | ||
} | ||
}, | ||
resolve: function (relativeId, module) { | ||
if (relativeId.charAt(0) !== '.') { | ||
@@ -23,0 +44,0 @@ if (relativeId in packages) { |
@@ -48,5 +48,10 @@ var Module = require('module'); | ||
requireModule.brow = require('./brow'); | ||
requireModule.config = require('./config').config; | ||
var configObject = require('./config'); | ||
for (var item in configObject) { | ||
requireModule[item] = configObject[item]; | ||
} | ||
requireModule.plugin = plugin; | ||
module.exports = requireModule; |
@@ -1,3 +0,7 @@ | ||
module.exports = { | ||
name: 'administrator' | ||
}; | ||
define(function (require, exports, modules) { | ||
exports.name = 'administrator'; | ||
exports.add = function (arg1, arg2) { | ||
return arg1 + arg2; | ||
}; | ||
}); |
@@ -1,1 +0,5 @@ | ||
exports.name = 'pow'; | ||
define(function (require, exports, modules) { | ||
module.exports = function (arg1, arg2) { | ||
return Math.pow(arg1, arg2); | ||
}; | ||
}); |
define(function(require, exports, module) { | ||
require(['./mod'], function(mod) { | ||
console.log(mod); | ||
}); | ||
module.exports = { | ||
@@ -7,0 +3,0 @@ mod: 'mod', |
define(function(require, exports, module) { | ||
return "mod"; | ||
return { | ||
name: 'modules' | ||
}; | ||
}); |
@@ -1,3 +0,1 @@ | ||
我是牛排 | ||
i am beef | ||
i am beef |
@@ -5,2 +5,3 @@ // 只有在入口文件才采用侵入方式 | ||
require.config({ | ||
name: 'source', | ||
baseUrl: './source', | ||
@@ -12,9 +13,9 @@ packages: { | ||
var mod = require('./mod'); | ||
var mod = require('source/mod'); | ||
require(['./amd'], function(amd) { | ||
require(['source/amd'], function(amd) { | ||
console.log(amd); | ||
}); | ||
var text = require('text!./text.txt'); | ||
var text = require('text!source/text.txt'); | ||
@@ -27,5 +28,3 @@ console.log(text); | ||
var fcpipe = require('mockservice'); | ||
// var css = require('css!./style.less'); | ||
// console.log(css); | ||
//var css = require('css!source/style.less'); | ||
//console.log(css); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
12629
21
312
104
15