-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Bundle ESM for Vue 3 prod #2205
Comments
This is interesting, I wouldn't use the native ESM for anything else than playing around but apparently, there are use cases. Do you have a demo with Vue Router as well? I remember people were struggling to get that working: vuejs/router#694 As for vue-demi, I don't think it will be adapted for the prod version as technically one could be using this in Vue 2 |
I added vue-router to the jsfiddle, they also use @vue/devrools-api but not vue-demi ESM should replace UMD, as the default option for sharing libraries, in my opinion. In my use case, we have different product teams developing “blocks” that can be used to create a page. But it gets harder to manage, and it's harder to use UMD when you want your bundles to be ESM, so you can leverage native dynamic imports, import.meta, etc. We started by keeping Vue 3 externalized by replacing at build type 'vue' with the url for the vue browser bundle. |
Thanks for the feedback, it's useful!
That would be great but it's still not possible due to Safari |
Wait, is ESM not working in Safari? What's the Safari blocker? |
Import maps |
They are supported on all evergreen browsers https://caniuse.com/import-maps And there is a polyfill that works for most of other browsers, giving a very high browser support |
Ah, I knew Safari had it, but it looks like it only just landed. Still, it looks like the technical blockers are gone. |
Hi @posva 👋 Since all browsers are at 91% globally supported and there are polyfills. How do you see this feature request going further? Is there any way we can help you implement this? Thank you very much and thank you @porfirioribeiro for the amazing feature request and detailing. 🚀 |
@Tragio Nothing has changed since Jun 14. Safari 16 (2023) still misses this feature. |
@posva I am running into a similar issue but for my current scenario I think publishing a Would it be ok to change the rollup configuration to also publish that one and create a pull request? |
Agree with this idea, I'm running into an issue about bundle size today which has been discussed in #1593, as for Webpack 4, the tree-shaking won't work as expect, it will bring another 20KB garbage into the chunk, even if I replaced {
resolve: {
alias: {
'pinia$': path.resolve(__dirname, './node_modules/pinia/dist/pinia.prod.mjs')
}
} |
What problem is this solving
I'm trying to use pinia in a microfrontends architecture, and we are planing to use importmaps to solve duplication of bundling dependencies.
So we're mapping pinia to https://cdn.jsdelivr.net/npm/pinia/dist/pinia.esm-browser.js
But it comes with some issues.
I have a working example https://jsfiddle.net/porfirio/qh8pf5xb/22/
Proposed solution
Have a new bundle without vue-demi and pointing directly for vue (3)
Probably create 2 bundles, one for prod without devtools, other for dev.
The pinia-esm-vue3 bundle, should only have the dependency on vue
Describe alternatives you've considered
It is possible to make it work, as-is, but it brings a lot of configuration that needs to be added
The text was updated successfully, but these errors were encountered: