0

I have this function:

function x(arg) { return arg.split(/(?<=\p{L})(?=\P{L})|(?<=\P{L})(?=\p{L})/ug); };

It doesn't work in Safari older than 16.4 (caniuse data), because of the lookbehind assertion. Instead, it produces a syntax error (as mentioned in another question)

However, BabelJS does not transpile it and also does not warn about it. I have specified targets as: last 5 safari version. Link to babel playground

When I use babeljs with a list of targets, I assumed that the transpiled result will work on all those targets. I know there's no direct transpilation for this lookbehind. However, babeljs should at least generate a warning that the lookbehind is not supported in the targets specified.

Is there any warning flag in babeljs to enable this? Or is this usecase solvable with another tool?

Gaurang Tandon
  • 6,504
  • 11
  • 47
  • 84

0 Answers0