Skip to content

build-ssg CLI crashes: Vite SSR throws "Invalid or unexpected token" when evaluating generated .less-ssg-entry.ts #2

@SisyphusZheng

Description

@SisyphusZheng

Body:

Description

deno task build:ssg (Phase 3 of the build pipeline) crashes immediately with a Vite SSR module evaluation error. The entire SSG build pipeline is unusable.

Steps to Reproduce

  1. Run deno task build (Phase 1+2 completes successfully)
  2. Run deno task build:ssg (Phase 3)

Error Output

[LessJS] Lit SSR adapter installed - TemplateResult to string
[vite] (ssr) Error when evaluating SSR module .less/.less-ssg-entry.ts: Invalid or unexpected token
    at new AsyncFunction (<anonymous>)
    at ESModulesEvaluator.runInlinedModule
    at SSRCompatModuleRunner.directRequest

Root Cause

The generated .less-ssg-entry.ts file contains:

  1. An __ssr() helper function using template literals (backtick strings) like `<${tag}></${tag}>`
  2. A massive ~7KB headExtras CSS string (JSON.stringify'd double-quoted) inlined into every route handler's wrapInDocument() call

When Vite SSR's AsyncFunction evaluator processes this mixed content (template literals + huge inline strings), it fails with "Invalid or unexpected token".

Environment

  • Deno 2.x + Vite 8.0.10 + @lessjs/core@0.9.2
  • Windows 11
  • Project uses resolveAlias pointing to local src-tmp/packages/ sources

Severity

P0 — The entire SSG build pipeline is completely broken. No static HTML output can be generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions