Skip to content

fix(vite): resolve workspace css specs to /@fs before ?inline transform - #11474

Merged
NathanWalker merged 2 commits into
NativeScript:mainfrom
aleclarson:fix/vite-css-inline-out-of-root
Sep 29, 2026
Merged

NathanWalker merged 2 commits into
NativeScript:mainfrom
aleclarson:fix/vite-css-inline-out-of-root

Conversation

@aleclarson

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

The .css branch of the /ns/m route compiles the stylesheet via sharedTransformRequest(${spec}?inline), where spec is the workspace-root-relative URL emitted by the pipeline (e.g. /packages/ui/src/theme/tokens.css). A root-relative URL only resolves under Vite's configured root, so for a monorepo workspace file the transform is denied, the branch silently falls through, and the device receives Vite's DOM-oriented CSS module:

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

(boot fails; the helper doesn't exist on NativeScript)

What is the new behavior?

The CSS branch anchors spec to the real file via /@fs/<root>/<spec> (probing project root first, then the monorepo workspace root) before the ?inline transform — the same /@fs resolution the module pipeline below already uses. In a monorepo the inline compile now succeeds and the device gets export default "<css>" + the __NS_REGISTER_CSS__ bridge call.

Fixes #11472.

Testing note

This code sits in the dev-server route handler, above the unit-testable helper layer — a spec would need a running ViteDevServer with the NS plugin. Verified via a minimal standalone repro exercising the exact transform gap on vite@8.3.0: https://github.com/aleclarson/repro/tree/nativescript-11472 — and end-to-end: this exact change (as a pnpm patch on 8.0.11) unblocked an HTTP-ESM dev boot that previously 404'd/fell through.

@nx-cloud

nx-cloud Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 18ca85f

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 3m 43s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-09-29 21:29:23 UTC

@pkg-pr-new

pkg-pr-new Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nativescript/core@11474
npm i https://pkg.pr.new/@nativescript/vite@11474
npm i https://pkg.pr.new/@nativescript/webpack@11474

commit: 18ca85f

@NathanWalker
NathanWalker merged commit 2050379 into NativeScript:main Sep 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants