sindresorhus/semver-regex

Firefox - SyntaxError: invalid regexp group

mfalade opened this issue · 2 comments

It looks to me like this library was built with Server side usage in mind.

On the client side, It throws an error SyntaxError: invalid regexp group on Firefox, (works fine in Chrome)

The error seems to be coming from the lookbehind in the first group in the regexp (?<=^v?|\sv?).

Can you please add support for client side environments ?

This module mainly targets Node.js, not the browser. It's up to you to transpile it with Babel if you want to use it in the browser. You can find a more detailed explanation here: sindresorhus/ama#446

If you use Webpack, check out babel-engine-plugin, which transpiles only the dependencies that needs to be transpiled.

If you use Create React App, upgrade to Create React App v2. It supports automatic transpilation of dependencies, which will make this package just work.

Are you sure babel transpiles such regex expressions too?
At the moment only Chrome supports this kind of regex lookbehinds.

It would be great if you could replace the lookbehind since this library can be also used for clientside validation.