Skip to content
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

Browser support without DNS check #26

Closed
edorivai opened this issue Aug 19, 2016 · 16 comments
Closed

Browser support without DNS check #26

edorivai opened this issue Aug 19, 2016 · 16 comments
Labels

Comments

@edorivai
Copy link

Hey!

This lib comes out on top when searching npms.io for email validators. However, due to the dependency on node's dns, we're unable to use it in the browser. In my case, I only want to use the simple, synchronous validation without the DNS check.

Would you guys consider not requiring dns for the synchronous case?

@Marsup
Copy link
Contributor

Marsup commented Aug 19, 2016

Why don't you just ignore dns in your bundler ?

@edorivai
Copy link
Author

Ah, managed to get it to work according to hapijs/joi#748 (comment)

Perhaps worth mentioning in the docs?

Thanks for the hint!

@Marsup Marsup self-assigned this Aug 19, 2016
@samhh
Copy link

samhh commented Nov 18, 2016

This seems like something that would surely be better fixed in the library itself, rather than polluting bundler configs?

@tuchk4
Copy link

tuchk4 commented Jan 5, 2017

node: {
  dns: 'mock',
  net: 'mock'
}

But this workaround will not work with create-react-app

@tuchk4
Copy link

tuchk4 commented Jan 5, 2017

Workaround for create-react-app

Setup NODE_PATH - directory name to be resolved to the current directory as well as its ancestors, and searched for modules. It is resolve.modulesDirectories for webpack. More details at node official doc "Loading from the global folders"

And then two ways:

  • create dns dir at the NOTE_PATH root and index.js inside
  • create dns.js file and the NODE_PATH root

Struct

Script source can be empty:

module.exports = {};

But also you could re-export dns mocks if needed.

@tamaccount
Copy link

Could someone perhaps add clearer instructions to this workaround? Perhaps the image tuchk4 provided better showed what he was describing but now the image is no longer working.

I am confused about:

  • where in my workspace to add the NODE_PATH folder and what should go in it?
  • and do I just include in the folder a js file called dns.js which simply reads
module.exports = {};

?

Any help would be much appreciated. Thank you.

@egonvb
Copy link

egonvb commented Apr 6, 2017

Here's my solution with create-react-app

create a folder dns ( mine is in src/mock/dns )
add file index.js to folder containing :

module.exports = {};
module.exports.default = {};

add file package.json to folder containing:

{
  "name": "dns",
  "version": "3.1.0",
  "private": true
}

Open your package.json and add following line to the dependencies

"dns" : "file:./src/mock/dns",

run "npm install"

@WesTyler
Copy link
Contributor

FWIW we are currently working on removing the dns dependency from isemail entirely. You can follow along here.

@arushi011
Copy link

@egonvb can you please make it more clear . I am stuck here

@egonvb
Copy link

egonvb commented Jan 14, 2018 via email

@WesTyler
Copy link
Contributor

Version 3 of this package no longer does the DNS checking, so that dependency is removed entirely. Let me know if you have trouble using version 3.

@sleepydistrict
Copy link

@WesTyler I just had this problem come up. It seems like what @egonvb suggested worked. Im going to move forward and find out.

@WesTyler
Copy link
Contributor

WesTyler commented Jan 29, 2018

@sleepydistrict can you confirm what version of isemail you're using? I just want to make sure this isn't an ongoing issue with version 3.

@benjiwheeler
Copy link

Sure seems to me like it's a problem that if you add isemail to your package.json, install it, and use it in your node code, it... makes your entire node app unusable

@WesTyler
Copy link
Contributor

WesTyler commented Aug 11, 2019 via email

@benjiwheeler
Copy link

I would suggest opening a new issue with some helpful details if this is an accurate description of your experience.

Fair!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants