lambdaisland/deep-diff2

Closure compilation failed

JarrodCTaylor opened this issue · 4 comments

When attempting to do a minified build the following error is thrown

Closure compilation failed with 1 errors
--- lambdaisland/deep_diff2/puget/color/html.cljc:42
Cannot convert ECMASCRIPT_2018 feature "RegExp Lookbehind" to targeted output language.

This seems to be the culprit:
image

This is code we inherited from Puget, but inlined when porting it to CLJC. Lookbehind is indeed a regex feature that is not universally available in JS engines yet.

A fix should be fairly easy though. This is really just trying to split a string that starts with an entity (e.g. < or  ) into the entity and the rest of the string. This could be done with subs and clojure.string/index-of.

Here's a sketch of what that could look like (untested)

(let [semicolon-pos (str/index-of span \;)
      escaped (subs span 0 semicolon-pos)
      span (subs span semicolon-pos)]
  ,,,)

Would you be interested in putting together a PR for this?

I will take a pass at it this weekend.

thankyou

Fixed in #18, thank you Jarrod!

Please feel free to comment here if this is still an issue for someone else 😄