Permalink
Browse files

fixes #59; lmd build ignores all optimisations of 3-party module; ver…

…sion 1.9.7
  • Loading branch information...
1 parent e0753eb commit fc10f07a166ff3792f4b2d5533c235617338f5c2 @azproduction committed Dec 2, 2012
View
@@ -1225,6 +1225,7 @@ LmdBuilder.prototype.build = function (config) {
case "fd":
case "fe":
case "plain":
+ case "3-party":
// #26 Code coverage
if (module.is_coverage) {
var skipLines = ({
View
@@ -5,7 +5,7 @@
"name": "Mikhail Davydov",
"email": "azazel.private@gmail.com"
},
- "version": "1.9.6",
+ "version": "1.9.7",
"bin": {
"lmd": "./bin/lmd"
},
View
@@ -21,7 +21,8 @@
if (!module) {
// if undefined - try to pick up module from globals (like jQuery)
- module = global[moduleName];
+ // or load modules from nodejs/worker environment
+ module = lmd_trigger('js:request-environment-module', moduleName, module)[1] || global[moduleName];
} else if (typeof module === "function") {
// Ex-Lazy LMD module or unpacked module ("pack": false)
var module_require = lmd_trigger('lmd-register:decorate-require', moduleName, require)[1];
@@ -26,7 +26,7 @@ var node_global_environment = {
}
};
}
- if (!/non_lmd_module\.js/.test(name)) {
+ if (!/non_lmd_module\.js/.test(name) && !/npm_module/.test(name)) {
throw new Error('NETWORK_ERROR');
}
@@ -108,4 +108,22 @@
typeof module.ololo === "function" &&
module.someVariable === "string", "require() can load plain 3-party non-lmd modules, N exports");
});
+
+ if (ENV_NAME === "Node") {
+ test("require() node.js npm, node, local modules", function () {
+ expect(3);
+
+ var module = require('npm_module_1');
+ ok(typeof module === "object" &&
+ typeof module.some_function === "function", 'require() + node:true can load nodejs npm modules');
+
+ module = require('./path/to/non_lmd_module.js');
+ ok(typeof module === "object" &&
+ typeof module.some_function === "function", 'require() + node:true can load node.js modules from local fs');
+
+ var fs = require('fs');
+ ok(typeof fs === "object" &&
+ typeof fs.readFile === "function", 'require() + node:true can load embedded node.js modules');
+ });
+ }
})

0 comments on commit fc10f07

Please sign in to comment.