UMD support
What problem does this feature solve?
no one think umd is better than directly declare a variable in window? for compatibility
vue 2 did this ,it is ok for most integration,is vue3 and vite was maintained by same team ? i think the design and code quality is goes down or some thing (techincal point) i miss understand casue my faulty view.
the vite old design and new issue https://github.com/vitejs/vite/pull/7948
https://github.com/vitejs/vite/issues/10822
and vue3 dist
What does the proposed API look like?
UMD support pls
I have trouble understand what supposed problem a UMD build would solve. I also don'T see the connection with the linked issues.
- Both a UMD and a IIFE build (our
vue.global.js
) will add a global variable calledVue
when directly included via a<script>
element i.e. from a CDN. Both won't add any other global variables. - a UMD build would also behave like a CommonJS file in a bundler-environment, but for that, tools like Vite would instead include the ESM build. Todays build tooling prefers ESM over CommonJS.
I I had to guess, your problem might be that you include the ESM build as a plain, non-module <script>
in the browser, which would simply be a mistake.
If you hav an actual bug to report, please do so in an issue with a bug report with a runnable reproduction
the way to solve the issue => close.
- HOW many npmpkgs now support esm bundle? * if majority not why not choice a sleek upgrade plan to step by step change it
- if vue use esm bundle use '.mjs' extention as a common principle
did UMD format bad as VAR VUE = XXXX
im not use it in a commonjs environment and i tested react、angular it's all works fine,but vue have problem and rise issue -> close twice.
so as a system designer in opensource, you think “we need teach our user how to use our product?”. and following the same pattern product same page is the goal?
or UMD is a big work of change?
i think neither. arrogant is.
You did not raise an issue, you opened a feature request - for a feature that i don't see necessary. If you rather think you have a bug, you should follow the issue guidelines and open an issue with a runnable reproduction.
I still don't really have any idea what the problem is that you are trying to describe. a runnable reproduction could clear that up.
If you hav an actual bug to report, please do so in an issue with a bug report with a runnable reproduction
in this issue i talk about 2 issue one is vue umd support,one is vite bundle of pollution global (and this have a link).
if the issue would be fix,just fix.in this case,i can switch to react and i can make a work around .
i'm not start project now,because the bundle formate problem,for me not have nessary to fix it .so let them exist,it's NOT my project,i think i'm a contributor of this,im not begger.current was tired of write issue about vue and vite
https://github.com/vitejs/vite/issues/10822#issuecomment-1341861250 other guys jump in and understand what im point,but vite need a reproduction to reproduce. and i was make a work around.
thats fine, if i use edit this comment estimated time it have already work around.
Bug reports require runnable reproductions. even us core contributors do follow that rule when we open issues ourselves. We ask the same from other people reporting problems. Runnable reproductions are required for us to be able to understand a problem clearly.
Now a few points, trying to explain my problems of understanding you.
- You first link to https://github.com/vitejs/vite/pull/7948 but this is a fixed issue in vite that affected IIFE as well as UMD, so I hav eno idea how this is relevant to your request.
- Then you point to https://github.com/vitejs/vite/issues/10822 which is about a problem with react, with one guy simply stating "I have this problem with Nuxt" - no reproduction.
- Finally in that same issue, you link to a previous bug report in this vue repository (https://github.com/vuejs/core/issues/7206), where again, you did not provide a runnable reproduction to understand in what circumstance you seem to have a problem with your IIFE and CommonJS builds.
Now we have another issue open, again with zero code to check out, and after all of these Issues I'm sorry to say I still don't understand the problem. Code would help. You don't want to provide code. So we will keep this issue closed.
i'm not start project now,because the bundle formate problem,for me not have nessary to fix it .so let them exist,it's NOT my project,i think i'm a contributor of this,im not begger.
Everyone is required to provide runnable reproductions in bug reports, even core contributors (i.e. https://github.com/vuejs/core/issues/7319). Us asking for a runnable reproduction of a problem is not us making you beg. It's us asking for minimal standards in order to be able to understand the problem.
ok ok,we need a runnable reproductions to debug it,screen shot or logs not enough,leave it and have a good day.
vite 或者是任何现代打包工具打包 Vue 3 都会默认引用 esm 格式,不存在全局变量污染。而 global 格式顾名思义就是暴露全局变量用的。
你的问题到底是什么,你并没有解释清楚。你自己觉得 umd 是唯一解决你问题的答案,我们觉得未必。你是不得不用一个不能处理 esm 的打包工具呢,还是错误的引用了 global 包呢,还是什么其他情况,你不提供重现,我们怎么可能知道?
另外,一个建议:调整下心态,加强一下沟通能力,好好说话。开源维护者不欠你任何东西,你如果不能心平气和的沟通,那我们也不会有兴趣解决你的问题,最终吃亏的是你自己。
早上一来看到这么多人点赞,细细一看,原来是家人们,那我把之前想说的也发上来。
========
我已经绕开这个问题自己搞完了,发这个 issue 只是觉得这个东西应该你们改,你们改更合适,改了能让大家都变好,已经说过了,我是拿自己当contributor 来提这个事情。你们有没有兴趣去解决这个问题跟我没什么关系,没有什么吃亏的,心态不要觉得别人总在求自己,我一般写 web 界面90%都用 react
从最开始的 issue https://github.com/vitejs/vite/issues/10822 讲为什么我觉得不 ok 了
- 构建产物的依赖不闭包直接放在 window 上真的合适吗?vite 构建的 bundle 引入了相同的框架库时在页面中有且只有一个,这些bundle是不是受自己控制,依赖的版本是否相容都没法解决,不存在全局变量污染这样单结论是不是给单太简单了? https://github.com/vitejs/vite/issues/10822#issuecomment-1308091718 我觉得这里去掉第一行的 iife 里面一堆的 var 已经可以说明问题了
- https://unpkg.com/browse/vue@3.2.45/dist/vue.runtime.global.js 这里只看2行,第一行和最后一行,这么写和实现一个 UMD 哪个更优雅呢?
我的问题也说的很明确 umd support,在另外的issue里也说过,我就不多说了,但是为什么在觉得自己会有更好的方案认为我的要求是不合理的,从上面两个问题我并不能看出来有这个势头。
家人们不欠你任何东西,别说家人们了,就是别人都会说,免费的你给你用都不错了还想要什么自行车就你p事多。没有问题,毕竟尤大都这么说了,是呀,开源社区都是免费的,就是今天 vue 直接删了那都跟我没关系,还不能谴责,要放平心态(开源真的免费吗?这个问题值得思考)我们换位思考下,一个 issue 提了一个多月被关掉,当家人们觉得我说话不好的时候,有没有想过,你们说话的方式?好心给路人给一块蛋糕,当着面丢进垃圾桶
我的问题也说的很明确 umd support,在另外的issue里也说过,我就不多说了
这个大概是最大的分歧点了,你觉得你已经讲清楚了,但是读的人可能并没能看懂……你提到的其他 issue 结合起来看也没有帮助我们准确理解到问题所在。
I have trouble understand what supposed problem a UMD build would solve
LinusBorg 回复的第一句就很能说明问题。
我是拿自己当contributor 来提这个事情
通篇读下来没有感受到“把自己当 contributor”,而是包含了很多反问和嘲讽性的语言。上面说的 “调整下心态,加强一下沟通能力,好好说话” 其实就是希望你不要用反问和嘲讽来讨论问题,仅此而已。你上面的回复明显是把这句建议本身也当作了嘲讽,然后开始用更加激进的语言回应了。
然而,你回复越冲,越不利于讨论和理解问题,恶性循环呀。不要带上主观恶意,冷静一下,好好讨论问题。
https://github.com/vitejs/vite/issues/10822 的问题是你没搞明白 Vite 的输出产物格式。vite build 的默认输出是 esm,需要用 <script type="module">
引入。你没有用 Vite 生成的 HTML 而是自己去掉了文件 hash 引入,但用的是普通的 <script>
而不是 esm script,所以才导致全局污染。这不是 bug,而是用法不对。
另一方面,这跟 Vue 是否提供 UMD 根本是不相干的问题,Vue 的 global build 就是专门用于非 ESM 的普通 <script>
场景的,暴露全局变量就是这个 build 的目的。你要打包就应该用 es modules 语法引入 esm build。这里有具体的解释。现代构建工具全部支持 esm,所以我们不觉得有提供 umd 的必要。
你想要 umd support,你得解释清楚为什么一定要有 umd support。https://github.com/vuejs/core/issues/7206 这里模糊的提到你的使用场景,但是信息完全不够。可能是你用的打包工具很特殊,不支持 esm,也可能是你在应该用 import 的场景下用了 require(),也可能是因为你还在用你在 vite 那个 issue 里用的错误用法,那么我们需要知道到底是什么情况,所以才会要求给重现。
直白点说,你对整个问题的理解从一开始就是错的,还把不相干的问题混到了一起,表达能力欠缺,态度上又咄咄逼人,我们能这样跟你说话已经很给面子了。
本 issue 下 Linus 的第一个回复很合理,完全没有任何问题。而你自己看一下你的第一个回复,各种反问,暗讽,说我们傲慢,如果你觉得你的沟通没有问题,我们可以 block 你,因为我们不欢迎你这样的用户。