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

Calling a method or property of another component using ref in one component raises an error when run build script, But running dev Script is normal #4896

Closed
7 tasks done
jzfai opened this issue Sep 10, 2021 · 4 comments
Labels
inconsistency Inconsistency between dev & build pending triage

Comments

@jzfai
Copy link

jzfai commented Sep 10, 2021

Describe the bug

image

image

Reproduction

yarn create vite
cd vite-project
yarn
add Children.vue component to HelloWord.vue
call Children func thought ref in HelloWord.vue
run build script

System Info

{
  "name": "vite-project",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "serve": "vite preview",
      "preview:build": "yarn run build && vite preview "
  },
  "dependencies": {
    "vue": "^3.2.11"
  },
  "devDependencies": {
    "@vitejs/plugin-vue": "^1.6.1",
    "@vue/compiler-sfc": "^3.2.11",
    "vite": "^2.5.6"
  }
}

Used Package Manager

yarn

Logs

vendor.df413e7c.js:1 TypeError: Cannot read property 'childrenFunc' of undefined
    at a (index.ea811d73.js:1)
    at go (vendor.df413e7c.js:1)
    at mo (vendor.df413e7c.js:1)
    at HTMLDivElement.n (vendor.df413e7c.js:1)

Validations

@github-actions
Copy link

Hello @jzfai. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@jzfai
Copy link
Author

jzfai commented Sep 10, 2021

git clone https://github.com/jzfai/vite-project.git

yarn run preview:build
click the red title to test
and then look the console info
@sodatea

@sodatea sodatea added pending triage inconsistency Inconsistency between dev & build plugin: vue and removed needs reproduction labels Sep 10, 2021
@sodatea
Copy link
Member

sodatea commented Sep 10, 2021

Bug in @vue/compiler-core: vuejs/core#4546
Will be fixed by vuejs/core#4549

@sodatea sodatea closed this as completed Sep 10, 2021
@sodatea
Copy link
Member

sodatea commented Sep 10, 2021

Workaround: use const refChildren = ref(null) instead of let.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
inconsistency Inconsistency between dev & build pending triage
Projects
None yet
Development

No branches or pull requests

2 participants