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 getCurrentInstance returns null (SSR) #1860

Closed
2 of 3 tasks
egoist opened this issue Feb 3, 2021 · 0 comments
Closed
2 of 3 tasks

Vue getCurrentInstance returns null (SSR) #1860

egoist opened this issue Feb 3, 2021 · 0 comments

Comments

@egoist
Copy link
Contributor

egoist commented Feb 3, 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

If I re-export Vue's getCurrentInstance from a package inside node_modules, it always returns null during SSR.

Reproduction

Create a package, for example:

packages/playground/ssr-vue/node_modules/foo/index.js:

export { getCurrentInstance } from 'vue'

packages/playground/ssr-vue/node_modules/foo/package.json:

{ "name": "foo" }

packages/playground/ssr-vue/App.vue:

<script lang="ts" setup>
import { getCurrentInstance } from 'foo'

console.log(getCurrentInstance())
//=> null in ssr
</script>

System Info

  • vite version: 2.0.0-beta.63 (main #b065ede3)
  • 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.
@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

1 participant