How to use esm version with CDN #2276
-
Vue version^3.4.21 Link to minimal reproductionhttps://github.com/juliusfriedman/vue-project Steps to reproduceRun project What is expected?Entire page loads What is actually happening? only displays html comment vnode No error in console etc. System InfoAll systems but only when externalizing all depencies in production mode, if I run in debug or if I remove the externalization for vue-router everything works as expected, if I instead try to internalize vue and externalize vue-router other strange issues occur. Any additional comments?See also my question about this same problem on StackOverflow Thanks in advance for your help! If you require any additional information please let me know and I will provide ASAP! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 7 replies
-
I cannot reproduce this issue on my end. need more information maybe relate to ur version |
Beta Was this translation helpful? Give feedback.
-
What can't you reproduce? Locally when I build in production mode I only see the component rendered on the Home page but not the imported data of the router-view. Are you saying when you build in production mode you are able to view the entire page and browse to home and about pages? Let me know what other information I could possibly provide.., Thank you! P.s Have tried multiple versions of vue and vue-router... and removing the line of vue-router from the externals definition solves the problem but costs another 80kb |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
FWIW I tried 2 different CDNS for vue and vue-router.. https://esm.sh/ Both seem to have issues where multiple versions of Vue somehow get imported... This brings me back to a problem with the library packaging or the library itself... Worst case we will collect scripts from vite and package them for use on our own CDN but I dont think we should have to, considering the tutorials say to use Vue and VueRouter from CDN I think this is something to investigate further. see |
Beta Was this translation helpful? Give feedback.
I recall esm.sh having more options to properly handle dependencies.
The issue you have right now is that jsdelivr imports different versions of vue. Check the vue-router cdn file:
That's why you have multiple versions of Vue and why things are breaking.
Another solution would be to use import maps like the playground.
That being said, if you want to benefit from tree shaking and load less js in your application, I would recommend you not to use a CDN version for vue, vue router and pinia (a full app). Vue router is also missing the production cdn version #2242