Skip to content

Type import in clientRouter causes "Failed to resolve module specifier" error #14724

@GabrielOnike

Description

@GabrielOnike

Astro Info

Astro                    v5.14.1
Node                     v20.12.1 
Package Manager          yarn
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/react

Describe the Bug

When using View Transitions(importing ClientRouter and ViewTransitions), the browser console shows an error:
Failed to resolve module specifier "astro:transitions/client"

This is caused by a type-only import on line 7 of the internal clientRouter.astro component:

import type { Options } from 'astro:transitions/client';

This type import is not being stripped during build and reaches the browser, causing a runtime error.

Reproduction

  1. Create an Astro project with View Transitions enabled while using ClientRouter and ViewTransitions
  2. Add View Transitions to a page
  3. Check browser console - error appears

Additional Context

tsconfig.json:

{
  "extends": "astro/tsconfigs/strict",
  "compilerOptions": {
    "allowJs": true,
    "jsx": "react-jsx",
    "jsxImportSource": "react",
    "strict": true
  }
}

What's the expected result?

Type imports should be stripped during compilation and not reach the browser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: view transitionsRelated to the View Transitions feature (scope)in reviewHas been triaged but not yet decided if it is a bug or not.needs reproIssue needs a reproduction

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions