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

ref is not defined when import.meta.glob is used when template has an html class #14242

Closed
olivervorasai opened this issue Jun 28, 2022 · 2 comments

Comments

@olivervorasai
Copy link

olivervorasai commented Jun 28, 2022

Environment


  • Operating System: Windows_NT
  • Node Version: v16.11.1
  • Nuxt Version: 3.0.0-rc.4
  • Package Manager: npm@8.10.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-h5grgg?file=app.vue

Describe the bug

When using import.meta.globEager with a ref, if the top-level element has a class, Nuxt will throw a 500 error stating ref is not defined

Here is a simplified version of the code

<script setup>
const assets = import.meta.globEager('/assets/*.svg', { as: 'raw' });

const someRef = ref('I am a ref');
</script>

<template>
  <div class="this-class-causes-an-error">
  </div>
</template>

Additional context

This may be not the same as #12806 since I am not using a dynamic path.

Logs

500
ref is not defined

at setup (./.nuxt/dist/server/server.mjs:3400:17)
at _sfc_main.setup (./.nuxt/dist/server/server.mjs:3430:23)
at callWithErrorHandling (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:157:22)
at setupStatefulComponent (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7084:29)
at setupComponent (./node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7039:11)
at renderComponentVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:172:17)
at Module.ssrRenderComponent (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:608:12)
at default (./.nuxt/dist/server/server.mjs:2672:37)
at Module.ssrRenderSuspense (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:946:9)
at _sfc_ssrRender (./.nuxt/dist/server/server.mjs:2667:25)
@danielroe
Copy link
Member

cc: @antfu - might be an unimport issue?

Reproducible with:

<script setup>
// /*
ref('I am a ref')
</script>

<template>
  <div class="this-class-causes-an-error" />
</template>

@antfu
Copy link
Member

antfu commented Jul 4, 2022

It's already been fixed in unimport v0.3.0, where our rc.4 still using v0.2.

Setting this to use the edge version until rc.5 gets released as an workaround

  "devDependencies": {
    "nuxt": "npm:nuxt3@latest"
  }

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