← 输入框|github.com|刷新
Skip to content

vite: workspace CSS imports served to device with __vite__updateStyle (undefined at runtime) #11472

Closed

Description

@aleclarson

Runtime error in @nativescript/vite (observed on 8.0.11, same code on main).

Description

In hmr/server/websocket-ns-m.ts the .css branch compiles via sharedTransformRequest(${spec}?inline), where spec is the root-relative URL (e.g. /packages/ui/src/theme/tokens.css). That path only resolves when the file lives under Vite's configured root. In a monorepo where shared packages live outside the app root, the ?inline transform misses, the branch falls through, and the device receives Vite's web CSS module which calls __vite__updateStyle — a helper that doesn't exist on NativeScript:

TypeError: undefined is not a function — __vite__updateStyle(...)

Observed with a workspace layout like apps/native (vite root) + packages/ui (shared package whose tokens.css is imported by the app entry).

Suggested fix

Resolve the specifier to its /@fs/<abs> form (or the real file path) before appending ?inline, so the transform works regardless of which root the file sits under. In our patched copy, routing the CSS branch through the same /@fs resolution the module path uses fixed boot; note the ?inline output shape also needs the export default "<css>" regex to match whatever the current Vite version emits.

Environment: @nativescript/vite 8.0.11, Vite 8.3, iOS simulator, pnpm monorepo.

Activity

  1. aleclarson commented on Sep 28, 2026

    @aleclarson
    ContributorAuthor

    Minimal reproduction: https://github.com/aleclarson/repro/tree/nativescript-11472 — a single Node script (npm install && node repro.mjs) that exercises the exact upstream function/code path and prints the failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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