Closed JacksonGL closed 4 years ago
In the minified releases, there is following code snippet (formatted for better illustration) that uses a variable before it was initialized:
var v = n(12), ..., E = '[' + O + ']{' + L + '}', // L is used ..., L = 2, ... // but initialized here
I traced back to the source:
import { MIN_LENGTH_FOR_NSN, VALID_DIGITS, ... } from './constants' ... const MIN_LENGTH_PHONE_NUMBER_PATTERN = '[' + VALID_DIGITS + ']{' + MIN_LENGTH_FOR_NSN + '}'
The concatenated string is used to construct a regex for matching phone numbers. It was supposed to be /...[0-90-9٠-٩۰-۹]{2}.../; now it becomes /...[0-90-9٠-٩۰-۹]{undefined}.../. Looks like this is a bug in the minifier.
/...[0-90-9٠-٩۰-۹]{2}.../
/...[0-90-9٠-٩۰-۹]{undefined}.../
I have replaced Webpack with Rollup. See if the new version libphonenumber-js@1.7.40 works.
libphonenumber-js@1.7.40
Looks like Rollup statically generates the string, which inlined MIN_LENGTH_FOR_NSN. So it works :)
MIN_LENGTH_FOR_NSN
In the minified releases, there is following code snippet (formatted for better illustration) that uses a variable before it was initialized:
I traced back to the source:
The concatenated string is used to construct a regex for matching phone numbers. It was supposed to be
/...[0-90-9٠-٩۰-۹]{2}.../
; now it becomes/...[0-90-9٠-٩۰-۹]{undefined}.../
. Looks like this is a bug in the minifier.