-
Notifications
You must be signed in to change notification settings - Fork 103
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
feat: parse vue components in text elements #744
feat: parse vue components in text elements #744
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/shopware-pwa/shopware-pwa-docs/5hgtpvs10 |
A couple of words on the code:
I hope I've done an acceptable job, if it seems alright I'll proceeds with what's missing (need some help on where to put code implementation and extraComponentsMap. Also, I need some help understanding how many components I should map and to which .vue file) |
This is great feature however I'm a little bit worried about the bundle size @patzick. Maybe we should load the parser dynamically just when it's really needed. The second idea is that maybe we should have this logic in kind-of a server-side service (filtering out the CMS content before it landed from the API - to streamline the client's side logic) |
Hi Piotr, bundle size is not an issue IMHO, the parser I've used is 600 bytes minified+gzipped. It's so small because it's based on regexes and assumes the HTML is valid XHTML (each tag is closed correctly). Generating the AST server side, therefore, doesn't change that much |
good thing this component is already lazy-loaded only when CMS text-element is used but @Rigo-m as
so it's almost 40kB for a single component. Do you see a way to use it without these two libs? The rest of it looks very promising, I'll test it shortly and dive deep into code :) |
Lodash can be cherry picked https://bundlephobia.com/result?p=lodash.isequal@4.5.0 (I'll do it while polishing the code), I'll find a solution for html-entities for sure, thanks for pointing that out. My goal right now is to publish a small library to npm to convert html to render functions, so that code implementation will be hidden behind the library (and also other people will be able to use it) I'll see if I can manage to implement @pkarw advices about lazy loading imports as well The end result will be something like export default {
render: function (createElement) {
return renderer(this.rawHtml, config, createElement)
}
[...]
} Sounds good to you? |
…ment in sw cms - refactor with html-to-vue library
# Conflicts: # packages/default-theme/package.json
… into feat/calls-to-action-parse-#649
…t-theme to nuxt-module
…xtraComponentsMap
… into feat/calls-to-action-parse-#649
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 🔥
Changes
closes #649 - Refactor CmsElementText.vue to have a render function that maps certain html elements to vue components
Checklist