Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to generate : prevRenderer issue #214

Closed
sl-nigelalmada opened this issue Jun 16, 2021 · 13 comments
Closed

Unable to generate : prevRenderer issue #214

sl-nigelalmada opened this issue Jun 16, 2021 · 13 comments
Labels
bug Something isn't working

Comments

@sl-nigelalmada
Copy link

sl-nigelalmada commented Jun 16, 2021

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

@sl-nigelalmada sl-nigelalmada added the bug Something isn't working label Jun 16, 2021
@github-actions
Copy link

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.

@magicmatatjahu
Copy link
Member

@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

@magicmatatjahu
Copy link
Member

magicmatatjahu commented Jun 16, 2021

@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! :)

@sl-nigelalmada
Copy link
Author

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

@sl-nigelalmada
Copy link
Author

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

Feel free to close the bug if needed

@jonaslagoni
Copy link
Sponsor Member

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

@magicmatatjahu
Copy link
Member

@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.

@jonaslagoni
Copy link
Sponsor Member

jonaslagoni commented Jun 16, 2021

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.

@jonaslagoni
Copy link
Sponsor Member

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

But still 😄

@derberg
Copy link
Member

derberg commented Jun 16, 2021

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

@magicmatatjahu
Copy link
Member

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

@jonaslagoni
Copy link
Sponsor Member

@magicmatatjahu guess you can revert it now 😆

@magicmatatjahu
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants