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

[Bug report]TypeError: __VUE_HMR_RUNTIME__.updatePageData is not a function #75

Closed
yyyanghj opened this issue Mar 20, 2021 · 5 comments
Closed

Comments

@yyyanghj
Copy link

Navigate failed and the console output TypeError: __VUE_HMR_RUNTIME__.updatePageData is not a function.
If I use Webpack as the bundler instead of Vite, everything will be OK.

Steps to reproduce

  1. git clone this repo reproduction link
  2. yarn install and yarn dev, then open http://localhost:8080/
  3. Click post button then see console output
  • Reproduction link / repo:

Expected behavior

Navigate to /post.html.

Screenshots

screenshot-20210320-173506

Environment info

  • Browser: Microsoft Edge 89.0.774.57
  • vuepress: 2.0.0-beta.3
  • vuepress-vite: 2.0.0-beta.2
@yzx9
Copy link
Contributor

yzx9 commented Mar 20, 2021

I ran into the same issue after bump to vuepress.beta.0

@meteorlxy
Copy link
Member

meteorlxy commented Mar 20, 2021

Will, there might be some conflicts with vueuse.

I think that's because we both reuse the __VUE_HMR_RUNTIME__ to handle HMR.

🤔 Seems vueuse does not handling HMR manually. So maybe vueuse somehow triggers HMR unexpectedly

@meteorlxy meteorlxy added bug Something isn't working package:bundler-vite labels Mar 20, 2021
@meteorlxy
Copy link
Member

meteorlxy commented Mar 20, 2021

I think you should add this config to vite when using vueuse.

https://github.com/vueuse/vueuse/blob/e3d727790f8233a671baac2b6292967b14bc2552/packages/vite.config.ts#L19-L23

@meteorlxy meteorlxy removed the bug Something isn't working label Mar 20, 2021
@meteorlxy
Copy link
Member

meteorlxy commented Mar 20, 2021

That's the solution:

module.exports = {
  bundler: '@vuepress/vite',
  bundlerConfig: {
    viteOptions: {
      optimizeDeps: {
        exclude: [
          '@vueuse/core',
        ],
      },
    },
  },
}

The reason is that vite pre-bundle @vueuse/core package, together with vue package. So there are two different "vue package instance", which caused this error.

@meteorlxy
Copy link
Member

If you are developing themes, consider following snippets:

https://github.com/vuepress/vuepress-next/blob/57967f7dec27c4148edf920decead327cc8746bf/packages/%40vuepress/plugin-nprogress/src/index.ts#L11-L23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants