1

I am currently working in a company where I have to fix a couple issue with IE11. One of the issues is only present in IE11 which centers around uuidv4 from node_modules.

the code at fault and the error that I am seeing is

Syntax error in regular expression

    /***/ (function (module, exports, __webpack_require__) {

        "use strict";
        //eval("

        var __importDefault = (this && this.__importDefault) || function (mod) {

            return (mod && mod.__esModule) ? mod : {"default": mod };};

            Object.defineProperty(exports, "__esModule", { value: true });
            const v4_1 = __importDefault(__webpack_require__(/*! uuid/v4 */ "../node_modules/uuid/v4.js"));
            const v5_1 = __importDefault(__webpack_require__(/*! uuid/v5 */ "../node_modules/uuid/v5.js"));
            const uuidv4 = function () {
                return v4_1.default();
            };

            uuidv4.regex = {
                v4: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u,
                v5: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u
            }; uuidv4.is = function (value) {

                return uuidv4.regex.v4.test(value) || uuidv4.regex.v5.test(value); 
            }; uuidv4.empty = function () {
                return '00000000-0000-0000-0000-000000000000';
            };

            uuidv4.fromString = function (text) {
                const namespace = 'bb5d0ffa-9a4c-4d7c-8fc2-0a7d2220ba45';
                const uuidFromString = v5_1.default(text, namespace);
                return uuidFromString;
            };

            exports.default = uuidv4;

            //# sourceURL=webpack://_chex/../node_modules/uuidv4/build/lib/uuidv4.js?");

            /***/
        }),

I did see and look to resolve what could have been one of the problems in the code in here changing

v5: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u

to

v5: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u

{4}-5 was the offending item in this regex, however IE11 still complains about the same issue.

But on closer inspection this is the line that it is complaining about

v4: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u,

When trying to put debugger statements in place, I cant hit these as before I get there and the code is being evaluated it fails and produces the error.

Any and all help on this will be gratefully received.

Simon Price
  • 3,011
  • 3
  • 34
  • 98

1 Answers1

3

The /u modifier was only introduced in ECMAScript 6 / ES2015, and IE11 only supports ES5 standard.

Since there are no specific constructs whose behavior is defined with the u modifier flag, you may simply remove u and your expression will work.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563