New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading of modules with main = path (./lib/) instead of main = path/file (./lib/index.js) #22
Comments
I'll fix it. For the For the validator module you may provide also a // validator/lib/validators.js
// ...
isIP: function(str) {
// net.isIp requires node >= 0.3.0
var modernNode = typeof net.isIP === 'function';
var method = modernNode? validators.isIPNet : validators.isIPManual;
return method(str);
},
isIPNet: function(str) {
return net.isIP(str) !== 0;
},
// ... |
It should work now. |
Awesome! That was fast ;) And for the web_module thing: I've sent a pull request for node-validator which removed the net-dependency. I was aware of the web_module way but fixing it at the module itself seemed to make more sense, because other people might want to use the module with webpack and browserify as well. |
I've publish it already, but it wasn't a change to Therefore webpack provides a syntax for module authors to provide different versions of node.js and webpack. validator could be organized this way: // validators.js
var isIP = require("./isIP"); // isIP.js
module.exports = require("net").isIP; // isIP.web.js
module.exports = function(str) {
// add some browser replacement here
} I proposed it for browserify here already: browserify/browserify#174 |
I had an issue today with bundling the validator node-module. I checked the package.json and the problem is how the main-file is referenced:
I changed it locally to lib/index.js and it works.
I think it's valid to reference main via path instead of a full-file-path, so webpack should resolve it the same way node does it.
And for testing with the validator module: Bundling the validator module doesn't work completely because it's referencing the native node-module "net". It removed this dep and it works completely.
The text was updated successfully, but these errors were encountered: