corenova / yang-js

YANG parser and composer
Apache License 2.0
56 stars 18 forks source link

Error happened during using yang-js in browser #146

Open Verten opened 1 year ago

Verten commented 1 year ago

When I try parse YANG model in browser, it throws error as below:

ERROR TypeError: Cannot assign to read only property 'module' of function 'function evaluate() {
          var _self;

          return (_self = self).eval.apply(_self, arguments);
        }'

here is the YANG model which I was parsed

            const schema = `
                module foo {
                  include foo-sub;

                  container foo {
                    leaf a { type string; }
                    leaf b { type uint8; }
                    list bar {
                      key "b1";
                      leaf b1 { type uint16; }
                      container blob;
                    }
                    uses fs;
                  }
                }`;

              const subSchema = `
                submodule foo-sub {
                  yang-version 1.1;

                  belongs-to foo {
                      prefix "foo";
                  }
                  grouping fs {
                    container fs {
                      leaf c {
                        mandatory true;
                        type string {
                            length "1..max";
                        }
                        description
                          "The alias of effective master key.";
                      }
                    }
                  }
                }`;

              let instance2 = (window as any).Yang.use(
                (window as any).Yang.parse(subSchema, { compile: false })
              );

              instance2 = (window as any).Yang.use(
                (window as any).Yang.parse(schema, { compile: false })
              );
              const compileResult = instance2.compile();

and error throw with this line image

could anyone help with this? or give some hints? thanks!