NativeScript / android

Android runtime for NativeScript (based on V8)

Home Page:https://docs.nativescript.org/guide/android-marshalling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug(alpha): SyntaxError: Invalid regular expression -> Regular expression too large

CatchABus opened this issue · comments

Environment

  • CLI: 8.1.5
  • Cross-platform modules: 8.2.0-custom.0
  • Android Runtime: 8.2.0-alpha.9

Describe the bug
It seems that V8 complains about regular expressions. The first problem I stepped into was related to a regular expression in NativeScript Color module:

An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function 
System.err: Cannot compile /data/data/com.fuelics.mobile.alpha/files/app/vendor.js
System.err: SyntaxError: Invalid regular expression: /^#([0-9a-f]{6}|[0-9a-f]{3}|[0-9a-f]{8})$/: Regular expression too large
System.err: File: (file: node_modules/@nativescript/core/color/color-common.js:5:0)

I shrinked regular expression manually but error persisted.

To Reproduce
Import @nativescript/core/color module. It makes use of hex regular expression inside helper functions like isValid.

Expected behavior
CLI should not complain about regular expression.

Additional context
There is a google bug report related to this issue here: https://groups.google.com/g/v8-reviews/c/9BbASYhUAmQ
Also, there is a reference of V8 regarding work on regular expression size handling:
https://chromium.googlesource.com/v8/v8/+/c9b71fac463dacde93fcc5ad77f56ba6ad7eeae6

@DimitrisRK how are you facing this ? using the alpha i 5 apps and never stumbled upon this

@farfromrefug It seems it's a bug that occurs under certain conditions.
In my app, I use import() or require() with dynamic expressions. See here: https://webpack.js.org/api/module-methods/#dynamic-expressions-in-import

It looks like this kind of imports makes CLI in latest alpha release go crazy and complain about regular expressions, which makes no sense.
Could this be a bug in latest v8 or webpack?

@DimitrisRK could you share a repro sample ?