asyncapi/html-template

Unable to generate : prevRenderer issue

sl-nigelalmada opened this issue ยท 13 comments

Describe the bug

Since today (16/06/2021) I'm unable to the HTML bundled file based on our AsyncApi doc
Maybe the issue is related to yesterday release ?

The error :

Something went wrong:
[...]/node_modules/@asyncapi/generator/node_modules/marked/src/marked.js:158
          const prevRenderer = extensions.renderers?.[ext.name];
                                                    ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> ([...]/node_modules/@asyncapi/generator/node_modules/@asyncapi/react-component/src/helpers/marked.ts:1:1)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

How to Reproduce

Use the command : npx ag spec.yaml @asyncapi/html-template --force-write -p singleFile=true -p outFilename=index.html

The package.json file sets the asyncapi/generator dependency at ^1.7.0

Content of the spec.yaml file :

asyncapi: 2.0.0
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  user/signedup:
    subscribe:
      message:
        $ref: '#/components/messages/UserSignedUp'
components:
  messages:
    UserSignedUp:
      payload:
        type: object
        properties:
          displayName:
            type: string
            description: Name of the user
          email:
            type: string
            format: email
            description: Email of the user

I tried to downgrade asyncapi/generator and/or asyncapi/html-template versions (by using a specific version in the npx command for asyncapi/html-template) but all my tries generates the same error

Expected behavior

Being able to generate the HTML file like before today

TIA

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.

Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sl-nigelalmada Hi! It's probably due to fact that one PR in the repo https://github.com/asyncapi/asyncapi-react in the next branch (we use underline the react-component to render the template) had updated the marked dependency where someone used the optional chaining in JS -> doc for that https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining

I will check that and I will give you the answer as soon as possible.

In meantime, could you write your NodeJS version? I know that writing for me it works is stupid, but I have 14.16.1 version and everything works :)

image

We changed the way of rendering the JSON examples (only styling) and I have it, so I use the newest version of template

image

@sl-nigelalmada As I thought, from this PR (merged 13 hours ago) people in markedJS started using the optional chaining, so please update your NodeJS at least to 14 version :) You can use the https://www.npmjs.com/package/n package to have several versions if you need. Please write if you need something more! :)

@magicmatatjahu I'm using NodeJS v12.22.1
I will evaluate the impacts of upgrading to 14+ I will get back to you

I have no issue with upgrading and it indeed works
Thanks for the insights

Feel free to close the bug if needed

This is a transitive bug received from markedjs/marked#2106. Time to downgrade the dependency?

@sl-nigelalmada Good to hear :)

@jonaslagoni I don't think so :P we should use always the latest 2.X.X version of marked, probably the maintainers will change the optional chaining to normal ? : statement.

Yea, but we cannot wait until they get that solved, who knows when? ๐Ÿ˜„

For now, we should probably downgrade the dependency so the users are not affected on our end.

Of course they do have a PR in progress - markedjs/marked#2109

But still ๐Ÿ˜„

yup, I agree with @jonaslagoni
they broke semver, but no clear answer in their issue when they will provide a fix, even though they are advanced markedjs/marked#2109

I created the PR asyncapi/asyncapi-react#371. After merging markedjs/marked#2109 I will revert changes :)

@magicmatatjahu guess you can revert it now ๐Ÿ˜†

If someone will have similar problems, please reopen the issue :)