Skip to content

ERROR: Unexpected "const" for srcset with space value for vitepress build #4839

@adiroiban

Description

@adiroiban

Describe the bug

I don't know if it's worth spending the time to fix it.

This is just to help other that might get this error

pnpm docs:dev works fine, but I got an error for pnpm docs:build

The error

$ pnpm docs:build

file: D:/GitHub/project/.vitepress/theme/ProductTour.vue?vue&type=script&setup=true&lang.ts:5:0

Unexpected "const"
3  |  
4  |  const _hoisted_1 = 
5  |  const _hoisted_2 = { class: "mt-10 flex w-full justify-center" }
   |  ^
6  |  const _hoisted_3 = { class: "pointer-events-auto hidden md:block" }
7  |  const _hoisted_4 = { class: "flex rounded-full bg-(--color-bg-highlight)/90 px-3 text-sm font-medium text-(--color-text-title) shadow-lg ring-1 shadow-(--color-text-highlight)/5 ring-(--color-text-title)/5 backdrop-blur-sm" }

[vite:esbuild] Transform failed with 1 error:
D:/GitHub/project/.vitepress/theme/ProductTour.vue?vue&type=script&setup=true&lang.ts:5:0: ERROR: Unexpected "const"
file: D:/GitHub/project/.vitepress/theme/ProductTour.vue?vue&type=script&setup=true&lang.ts:5:0

Reproduction

The HTML that trigger this error is:

<template>
<img srcset=" "/>
</template>

There is no error for

<template>
<img srcset=""/>
</template>

Expected behavior

The error link to the line at which the srcset attribute is set.

System Info

> @ envinfo D:\GitHub\sftpplus.com
> envinfo --system --npmPackages vitepress --binaries --browsers


  System:
    OS: Windows 11 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 4800HS with Radeon Graphics
    Memory: 3.81 GB / 15.42 GB
  Binaries:
    Node: 24.2.0 - D:\GitHub\sftpplus.com\build-website\nodeenv\Scripts\node.EXE
    npm: 11.3.0 - D:\GitHub\sftpplus.com\build-website\nodeenv\Scripts\npm.CMD
    pnpm: 10.12.1 - D:\GitHub\sftpplus.com\build-website\nodeenv\Scripts\pnpm.CMD
    bun: 1.2.16 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (137.0.3296.68)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    vitepress: ^2.0.0-alpha.6 => 2.0.0-alpha.6

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildRelated to the build system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions