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

Issue with optimizeDeps #1408

Closed
3 tasks done
izadiegizabal opened this issue Jan 7, 2021 · 4 comments
Closed
3 tasks done

Issue with optimizeDeps #1408

izadiegizabal opened this issue Jan 7, 2021 · 4 comments

Comments

@izadiegizabal
Copy link

izadiegizabal commented Jan 7, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

While upgrading from 1.0.0-rc.13 to 2.0 the optimizeDeps stopped working for the dependency I was using. Before (in v1.x), it was not detected automatically and had to add it to the optimizeDeps.include property in the vite.config file; now, it does gets auto detected but it gives me the following error in the browser once vite finishes building:

Uncaught SyntaxError: The requested module '/node_modules/vue/dist/vue.runtime.esm-bundler.js?v=3.0.5' does not provide an export named 'default'

However, if I exclude the dependency optimization (optimizeDeps.exclude) I get the original message I was getting in v1.x before explicitly asking to optimize this dependency:

Uncaught SyntaxError: The requested module '/node_modules/vue-cal/dist/vuecal.common.js?v=4.2.0' does not provide an export named 'default'

I don't know if missed any step in the migration guide or what is causing this issue, any help would be really appreciated.

Reproduction

I've created a small repo with the template vue-ts project with this dependency added.

Just by running npm run dev you should be able to see the error message in the browser.

System Info

  • vite version: 2.0.0-beta.9
  • Operating System: macOS 11.1 (Big Sur)
  • Node version: 14.9.0
  • Package manager (npm/yarn/pnpm) and version: npm 6.14.10

Logs

Vite's output looks normal, it doesn't give any error or warning.

@physihan
Copy link

physihan commented Jan 7, 2021

I run with the same problem, it seems like that the typescript file vue component only compatible with typescript one,while when you use javascript component then the error occur.

@yyx990803
Copy link
Member

yyx990803 commented Jan 7, 2021

So - this is technically because vue-cal distributes a webpack-bundled dist file that attempts to require('vue'), but Vue 3 no longer has default exports. It's fixed by optimizing Vue alongside vue-cal, but breaks when Vue is treated as native es modules.

I would recommend library authors to start using Vite to build and distribute libraries targeting Vue 3.

@kondr1
Copy link

kondr1 commented Jun 1, 2021

I have same problem with oidc-client =(

@github-actions
Copy link

This issue has been locked since it has been closed for more than 14 days.

If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants