Skip to content
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

vue bundle problem of use in require js like common js module #7206

Closed
joebnb opened this issue Nov 24, 2022 · 2 comments
Closed

vue bundle problem of use in require js like common js module #7206

joebnb opened this issue Nov 24, 2022 · 2 comments

Comments

@joebnb
Copy link

joebnb commented Nov 24, 2022

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

@posva
Copy link
Member

posva commented Dec 3, 2022

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.

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2022
@joebnb
Copy link
Author

joebnb commented Dec 8, 2022

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

@LinusBorg LinusBorg mentioned this issue Dec 12, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants