vue bundle problem of use in require js like common js module
Vue version
3.2.45
Link to minimal reproduction
if require as unpkg(dist/vue.global.js) ,it will throw undefined because it's warped with a IIFE and break exports in vue.global.js:
(function (exports){
var Vue = vue code
// here pass a object break common js make right export
})({})
Steps to reproduce
in vue package.json main and unpkg field should return commonjs and universal module definition.
if require path as main defined(index.js) it will require 'fs' , it will throw exception in browser env by it's dependencies
{
"name": "vue",
"version": "3.2.45",
"description": "The progressive JavaScript framework for building modern web UI.",
"main": "index.js",
"module": "dist/vue.runtime.esm-bundler.js",
"types": "dist/vue.d.ts",
"unpkg": "dist/vue.global.js",
"jsdelivr": "dist/vue.global.js",
"files": [
.....
in my app i wrote a warpper like:
function (require,exports,module){
// exports can't working well because a {} replaced exports
`${vue.global.js}`
}
i think the out put should relate on some common definition,
What is expected?
adapt with UMD or CMD module definition
What is actually happening?
throw error
System Info
No response
Any additional comments?
No response
The unpkg entry isn't supposed to be directly required, it's normal it doesn't work. The exports are, in this case, correct. If anything, we could add extra exports
as proposed in other issues.
The unpkg entry isn't supposed to be directly required, it's normal it doesn't work. The exports are, in this case, correct. If anything, we could add extra
exports
as proposed in other issues.
i think unpkg bundle should use UMD definition to do this.not directly put this in window. it's lost expansibility