-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
chore: add esm, cjs and umd bundles #297
chore: add esm, cjs and umd bundles #297
Conversation
a9d6674
to
6083816
Compare
6083816
to
99473a8
Compare
}, | ||
|
||
plugins: [ | ||
// new BundleAnalyzerPlugin(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BundleAnalyzerPlugin
is used to check size of bundled package on prepared for that html-site. I don't wanna remove it from code, but only comment when someone will want to check the size before commit (with new changes in component).
@@ -0,0 +1,146 @@ | |||
import React, { Component } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the old AsyncAPI
component but without parser. "New" AsyncAPI
component uses this component directly in render
function to avoid repetitive code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks fine, just one comment so I can understand something
library/src/components/Schema.tsx
Outdated
@@ -153,7 +161,7 @@ export const Schema: React.FunctionComponent<Props> = ({ | |||
key={idx} | |||
className="border inline-block text-orange-600 rounded ml-1 py-0 px-2" | |||
> | |||
<span>{e}</span> | |||
<span>{JSON.stringify(e)}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you explain why now we need to stringify this and const? I thought it is string always
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON.stringify
add to string ""
, similar to Nunjucks something | safe
. I think that I should make some helper
to "prettiefy" these string, not using JSON.stringify.
I have to shamefully confess I don't get why it is so important to support all these different bundlers. It only makes me feel there are moments where I feel tired with JS ecosystem complexity 😄 |
also strange that with so many modifications there was no need to update/add any tests 😝 |
@derberg Agree with you with JS ecosystem complexity! 😅 I will try to explain why we need it (for community of course):
Feel free when you have another questions!
PR adds only configurations for the webpack, in which way you want to test it? 🤣 |
just wanted to point out I'm missing components tests in overal 😛
thanks for that, please update description with this comment so it is clear for anyone in the future and there is no need to scroll through comments I also think we need some info about it in the readme, don't you think? btw, you think it will solve issue with next.js? as a side effect :D |
@derberg I'm kidding with tests, I know about it, at the moment I need only this PR, some changes with styling, updated Readme and I'm on the way to merge to master. I think that on Monday I will have the last PR to merge before merging to master and I will think about missed tests to helpers. Component testing 🤔 I don't know if it's needed, because we don't have any interactivity in them.
I tested umd module in studio and it works, so yeah, as a side effect I fixed these problems with next.js, but at the moment, I don't want to write about it in these issues. |
you mean you want me to approve and update readme in final PR? |
I will write helper to prettify string from |
ok, but please remember about the explanation for different modules, as I will forget to check that explicitly also, hint for final PR -> would be awesome to have playground deployed from the branch, somewhere, for manual testing + webcomponent available for test too |
👌🏼
I planned to add instruction how to install html-template with new component onboard |
I think deploying playground from your branch would make it super easy for others to take a look and try out their files, to give you a good feedback. anyway, approving |
Kudos, SonarCloud Quality Gate passed! |
@derberg I added missed function. I see that I have possibility to merge, so I'm merging :) Thanks for review! |
🎉 This PR is included in version 0.21.0-next.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
Changes proposed in this pull request:
esm
bundle undermodule
field,cjs
bundle undermain
field,umd
bundle under{package}/bundles/umd
directory.package.json
with helper scripts.dompurify
toisomorphic-dompurify
to support rendering in node and in browser - originaldompurify
can only be used in browser.AsyncAPI
with parser andStandalone
without parser -- for these two bundler creates two umd packages.ems
is prepared when you use something likecreate-react-app
when someone have another bundler (webpack) to bundle our component with another application. Only for better DX.cjs
is prepared only for application when you use CommonJS (require
,module.exports
). There is also not needed to bundle our package by webpack, because on the Node app should deal with the dependencies of our component.cjs
is only needed for rendering on the server side (hydration), when someone usecjs
, otherwise will be usedesm
.umd
can be used on Node side and client side (browser), but unfornatelly we are using parser in our component which needs a Node polyfills to run on browser, soumd
is only needed when someone wants to run a component as a script in html - something like webcomponent but run from react. For umd I created two packages, with and without parser, but you know why we need it :)Related issue(s)
Part of asyncapi/shape-up-process#105