vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Uncaught ReferenceError: can't access lexical declaration 'K' before initialization #3717

Closed gander closed 1 month ago

gander commented 1 month ago

Describe the bug

Uncaught ReferenceError: can't access lexical declaration 'K' before initialization
    vi https://preview-extend-template.gander-pl.pages.dev/assets/chunks/framework.v9o0AzEe.js:13
    <anonymous> https://preview-extend-template.gander-pl.pages.dev/assets/chunks/theme.DDSRElNe.js:1
framework.v9o0AzEe.js:13:10217

Reproduction

.vitepress/theme/index.js

import { h } from 'vue'
import DefaultTheme from 'vitepress/theme'
import Footer from "./Footer.vue";

export default {
    extends: DefaultTheme,
    Layout() {
        return h(DefaultTheme.Layout, null, {
            'layout-bottom': () => h(Footer)
        })
    }
}

.vitepress/theme/Footer.vue

<script setup>
const telemetryImg = import.meta.env.VITE_TELEMETRY_IMG;
</script>

<template>
  <div class="telemetry" v-if="telemetryImg">
    <img :src="telemetryImg" alt="">
  </div>
</template>

<style scoped>
.telemetry {
  text-align: center;
}
.telemetry img {
  display: inline-block;
  max-width: 66px;
}
</style>

Expected behavior

Display image in footer

System Info

System:
    OS: Linux 6.5 Linux Mint 21.3 (Virginia)
  Browsers:
    Chrome: 123.0.6312.86
  Cloudflare:
    Node: 20.5.1
    bun: 1.0.35

Additional context

https://preview-extend-template.gander-pl.pages.dev/

Validations

brc-dd commented 1 month ago

Seems like a circular reference. Which environment variables should be set locally to reproduce this? It's not reproducible by just cloning and building.

gander commented 1 month ago

@brc-dd

VITE_TELEMETRY_IMG=https://up.gander.pl/telemetry/clnzoxcy10001vy2ohi4obbi0/cltzm76630002p94d9omanfh2/badge.svg

Occurs after deploy:

brc-dd commented 1 month ago

Still not reproducible:

image

Most likely is being caused by something else. Try disabling sentry once and re-deploying.

gander commented 1 month ago

Removed all Sentry code, and still occurs: https://preview-rid-sentry.gander-pl.pages.dev/

obraz

brc-dd commented 1 month ago

I'm still seeing sentry stuff in your site 👀

image
gander commented 1 month ago

That's weird. This plugin should only be run while building, but I see it leaving a lot of baggage.

gander commented 1 month ago

This was definitely it. After restoring the normally working Sentry, but removing the Sentry Release plugin, it stopped throwing the error there. Thanks for the help!