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

_unref not defined on build #14203

Closed
StevenJPx2 opened this issue Jun 21, 2022 · 6 comments
Closed

_unref not defined on build #14203

StevenJPx2 opened this issue Jun 21, 2022 · 6 comments

Comments

@StevenJPx2
Copy link

Environment

Nuxt CLI v3.0.0-rc.4
RootDir: /Users/stevenjohn/Documents/Projects/SAFT/website-v2
Nuxt project info:


  • Operating System: Darwin
  • Node Version: v18.1.0
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: yarn@1.22.15
  • Builder: vite
  • User Config: buildModules, vite, build
  • Runtime Modules: -
  • Build Modules: @vueuse/nuxt@8.7.4

Reproduction

Minimal reproduction

Describe the bug

When a value from a composable is used in a v-bind in CSS, it fails in previewing the build, giving the error _unref is not defined.

Glue fix for people who are facing this issue

Just add this to the top of your vue file wherever you have this use-case:

<script setup>
import {unref as _unref} from 'vue';

// ...
</script>

What I've found

In server.mjs: it is resolving the composable ref value using _unref instead of using vue_cjs_prod.unref. When I did that to the build file, it ran with no issue.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

danielroe commented Jun 21, 2022

This looks like it might be an auto import issue.

cc: @antfu

@antfu
Copy link
Member

antfu commented Jun 21, 2022

Weird your repro works fine on my side
image

@StevenJPx2
Copy link
Author

StevenJPx2 commented Jun 21, 2022

It will work on dev, and I'm stackblitz it still works fine in build, but you do get the error message saying that _unref is not defined in the console. When I hosted it on Netlify and also tried running it locally, it kept crashing the entire website.

@DamianGlowala
Copy link
Member

DamianGlowala commented Jun 21, 2022

@antfu, I have also discovered a weird behavior, might be related to this (ignore underlined ESLint-related v-model warnings).

When I run npm run build with the following indentation of lines 207-209, this is the error that gets shown:

image

On contrary, when I manually change what ESLint split into three lines to a single line statement, the error isn't shown anymore :)

...that is: v-model:number-of-items-per-page="numberOfItemsPerPage"

numberOfItemsPerPage is a ref()

@cainaf
Copy link

cainaf commented Aug 27, 2022

i get exactly the same error when using v-bind in css from a composable value (rc.8)... oddly enough it happens only in a couple files where others (also using the same v-bind from the same composable value) the error does not occur. i couldn't understand why

it happens only when running after a build. dev is fine.

@StevenJPx2 suggestion of importing import {unref as _unref} from 'vue'; did solve the problem

@antfu
Copy link
Member

antfu commented Aug 29, 2022

This is a Vue bug, close as duplicated for #14550

@antfu antfu closed this as completed Aug 29, 2022
@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
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

5 participants