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 unref error #1661

Closed
2 of 3 tasks
anncwb opened this issue Jan 23, 2021 · 20 comments
Closed
2 of 3 tasks

vue unref error #1661

anncwb opened this issue Jan 23, 2021 · 20 comments

Comments

@anncwb
Copy link
Contributor

anncwb commented Jan 23, 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

@yyx990803 I think there will be many such problems in this update

<script lang="ts">
  import { defineComponent, ref, unref } from 'vue';
  export default defineComponent({
    name: 'App',
    setup() {
      const count = ref(0);
      console.log(unref(count));
      return {};
    },
  });
</script>

Reproduction

git clone https://github.com/anncwb/vite-bug
yarn && yarn serve

image

System Info

  • vite version:beta.41
  • Operating System:
  • Node version:
  • Package manager (npm/yarn/pnpm) and version:

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
@yyx990803
Copy link
Member

fixed in beta.42

@anncwb
Copy link
Contributor Author

anncwb commented Jan 23, 2021

@yyx990803 I really think it hasn't been fixed yet. I upgraded to beta42 in the minimal example and can run. But my full version of the project still prompts unref errors. I will try to reproduce this problem

@yyx990803
Copy link
Member

Do you have other dependencies that import/requires Vue?

@anncwb
Copy link
Contributor Author

anncwb commented Jan 23, 2021

I’m troubleshooting, it may take some time to find out where the problem is

@anncwb
Copy link
Contributor Author

anncwb commented Jan 23, 2021

Do you have other dependencies that import/requires Vue?

yes

@yyx990803
Copy link
Member

Can you list them? Also check if any of them contains require('vue') calls...

@anncwb
Copy link
Contributor Author

anncwb commented Jan 23, 2021

I checked the problem with this package @vueuse/core

@anncwb
Copy link
Contributor Author

anncwb commented Jan 23, 2021

@anncwb
Copy link
Contributor Author

anncwb commented Jan 23, 2021

After I excluded this, there were other packages that had problems. I will reopen the issue after finishing finishing. thank

@ResuBaka
Copy link

I have the same problem, but it looks like an issue with ssr and the use of @vue/server-renderer as it contains require('vue').

Even when I do not use ref and just render the image from default App.vue I get this error: Uncaught SyntaxError: The requested module '/node_modules/.vite/vue/dist/vue.runtime.esm-bundler.js?v=889f8a29' does not provide an export named 'openBlock'.

@yyx990803
Copy link
Member

I think it should be fixed by 4c4d629.

@ResuBaka @vue/server-renderer should be moved to devDependencies or excluded for optimization.

@yyx990803
Copy link
Member

Try beta.43!

@anncwb
Copy link
Contributor Author

anncwb commented Jan 23, 2021

@yyx990803 It can run normally. thank

@ResuBaka
Copy link

@yyx990803 Thanks for the answer and that fixed it.

@anncwb
Copy link
Contributor Author

anncwb commented Jan 26, 2021

@yyx990803 After updating to beta.48, this problem reappeared, because it is the same problem, so I did not create a new one, please forgive me。
It is this package that caused the problem https://github.com/vueuse/vueuse

@anncwb
Copy link
Contributor Author

anncwb commented Jan 26, 2021

image

@yyx990803
Copy link
Member

Hmm, are you sure? I just ran your last reproduction with beta.49 and it works just fine. You may have other deps that are causing the issue.

@yyx990803
Copy link
Member

It seems you are importing unref from @vueuse/core instead of vue.

@anncwb
Copy link
Contributor Author

anncwb commented Jan 26, 2021

I am trying to reproduce it. Because of this error in my project, as long as "@vueuse/core": "^4.0.10" is added to dependencies, it will appear. Otherwise, the project will run normally after removal. It is only added to dependencies and not referenced in the code. That’s why I initially determined that this was the problem

@anncwb
Copy link
Contributor Author

anncwb commented Jan 26, 2021

@yyx990803 I have updated github. You can pull again. It’s amazing that I’ve tried a lot of this error. The error will only appear when the following dependencies are included. Delete one of them and the error will disappear. I don’t know if this error is vite fault

image

"dependencies": {
    "@iconify/iconify": "^2.0.0-rc.6",
    "@vueuse/core": "^4.0.10",
    "ant-design-vue": "2.0.0-rc.9",
    "apexcharts": "^3.23.1",
    "axios": "^0.21.1",
    "crypto-es": "^1.2.6",
    "echarts": "^4.9.0",
    "lodash-es": "^4.17.20",
    "vue": "^3.0.5"
  },

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

3 participants