blake-regalia / graphy.js

A collection of RDF libraries for JavaScript
https://graphy.link/
ISC License
161 stars 3 forks source link

SyntaxError: invalid regexp group error with Firefox (using Svelte) #18

Closed happybeing closed 4 years ago

happybeing commented 4 years ago

Are you aware of any problems when using graphy with Firefox?

As you know I've been checking out Svelte with graphy and when I had a bundling problem I switched from rollup to webpack. This helped as I can now use graphy (and rdflib.js which was my first try) in Chrome using Svelte 3.

However in Firefox and for graphy only I am getting a console error: SyntaxError: invalid regexp group for bundle.js.

This appears to happen early on when loading because no sources are listed in the debugger and clicking on the error opens a text listing of the webpack bundle in the browser! So my first thought was it ought not to be to do with graphy, but as noted I don't have this issue with rdflib.js in the same project.

I have one component importing rdflib.js with const rdflibx = require('rdflib'); (working in Chrome and Firefox) and a different component that does const readTtl = require('@graphy/content.ttl.read'); which works in Chrome but gives the error in Firefox.

I'm adding Svelte components to test use of Rdfjs and LDFLex at the moment. The repo has the latest versions of the components (but not the webpack config or App.svelte I think) here: https://github.com/theWebalyst/svelte-with-rdf-libs-webpack

blake-regalia commented 4 years ago

Confirmed. This is caused by a negative lookbehind regexp which should be getting polyfilled by a try/catch block but it seems that Firefox throws an uncatchable parsing error for the offending regexp code. I will have to refactor this to strings and the RegExp constructor somehow.

blake-regalia commented 4 years ago

Funny enough, MDN's article about browser detection addresses this exact issue about SyntaxErrors caused by unsupported RegExp features.

blake-regalia commented 4 years ago

Fixed in v4.0.3 -- will open issue to add testing in Firefox in addition to Chrome.

happybeing commented 4 years ago

:+1: Confirmed fix! Your service is amazing - thanks :smile: