spamscanner/url-regex-safe

browser friendly

Kikobeats opened this issue · 6 comments

Hello,

I'm opening this issue because, although I adopted url-regex-safe instead of url-regex, recently discovered url-regex-safe depends on re2 and it isn't a suitable browser dependency:

uhop/node-re2#77 (comment)

There is a proposition to make re2 browser friendly

uhop/node-re2#18

but until that happens, this is making me not possible to adopt url-regex-safe

not sure if you have an opinion about that, just I wanted to warn you 🙂

This does work in the browser. I made it so it doesn't require re2 in the browser, see package.json and the code.

Hum I think you're right and actually, the error I'm experimenting with is the environment where the code is running can't compile re2 properly

at runkit.com

Screen Shot 2020-10-14 at 00 43 32

at vercel.com

Screen Shot 2020-10-14 at 00 42 55

which is also a pain, any idea what's happening?

If you can share a reproducible repo I could try to find time to look at this, guessing its a bundler issue or yarn/npm. What version of Node are you on?

Same here, I can't use in a simple Vue app

Cannot find module './build/Release/re2' from 're2.js'

Is it possible to be related with re2 install script not being called?

install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR || npm run rebuild.

Maybe url-regex-safe can't find the re2 module because the .node file wasn't installed yet.

const RE2 = require('./build/Release/re2');

The solution may be to use lazy import with re2 or url-regex-safe.