-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Parser does not work out of the box in non-node environments (websites) #344
Comments
you mean the generated bundle doesn't work or? |
@derberg when the parser is a secondary dependency, i.e. when I import Modelina in the website, it is using the default package. This simply cannot be used as-is since the dereference logic throws an error, because the path |
@jonaslagoni Did you try import the bundle from |
@jonaslagoni don't tell me you did not read the docs and spent time on reporting an issue 😛 |
@derberg @magicmatatjahu so you want me to import But only when used in browsers? 🤨 That does not make sense to me? Especially since the only thing not working in the parser is the dereference logic...
It is not me that is importing the parser, Modelina is, I am just using it (Modelina). But yes, I read it, I just don't think it applies here 😄 |
Ok I see... I was face with similar problem one time when I tried run the react-component in the NextJS app and fix the issue - asyncapi/asyncapi-react#197 and as I remember the NextJS under the hood has custom webpack which will transform the code to the optimized bundle, but problem is how it it handles the node-related packages like But about NextJS... If you have enables the SSG (static site generator) then NextJS tries to use the browser-compatible packages of your imports, so it will try to bundle (by default by Webpack4) the parser to the compatible browser version and replace the I thought that only react-component will have such an issues related to the parser, but as I see also the modelina have such an issues... Maybe we should start investigation how to write two corresponding Parser classes, one for node and one for browser? This second shouldn't use the node-related dependencies (of course with full support of tree-shakable). What do you think? |
@magicmatatjahu I think that makes sense, but in many cases, I dont think that the node-related dependencies matter (any more or at least in some environments), as for example in the website when I used Modelina, all it complained about was that it could not dereference You can see the "workaround" here: https://github.com/asyncapi/website/blob/3b18f671784670cb9740e3d262ed4c0c57139d58/pages/modelina.js#L86. I am however relying on the transitive dependency from Modelina (for the parser). So in most cases, the parser could be used as-is in many cases, and in special website environments it would need the non-node-related dependency version 🤔 Or am I missing something? |
Exactly, in some environments it can be handy to have node-free Parser. However, I am glad that workaround works, but tbh... 😅 We don't use such an input (I mean option to the |
@magicmatatjahu it is because of this (when I don't use the bundled package version):
I doubt many use it in this combination between node and website versions, as many probably switch to the package version |
I am curious because we also use the normal package in the react-component - https://github.com/asyncapi/asyncapi-react/blob/next/library/src/helpers/parser.ts#L1 and everything works. |
🧐 That is weird yea... Gonna remove |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
thb I still don't really understand what is the issue and why bundle.js is not good enough |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
@jonaslagoni any updates? |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
I have not looked at this since.
The "issue" is that Line 45 in aba3ed2
I think the way forward is one of these:
|
shouldn't https://github.com/asyncapi/parser-js/pull/572/files fix the issue? |
🎉 This issue has been resolved in version 1.16.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This issue has been resolved in version 2.0.0-next-major.18 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Describe the bug
If the parser is utilized in a website the
path
parameters is a requirement to set, in order to make the library work.How to Reproduce
Given the AsyncAPI document:
and the following code:
which forces the
path
parameter:This is because the following code:
parser-js/lib/parser.js
Line 45 in aba3ed2
Where in a browser environment
process.cwd()
returns/
andpath.sep
returns/
which together (//
) is an incorrect path and it will throw an exception once it begins the dereference process.Expected behavior
Expected the parser to work out of the box without any modification and ensure the default path is always valid.
The text was updated successfully, but these errors were encountered: