Skip to content

Cannot use .tsx files in static file endpoints #9588

@orf

Description

@orf

Astro Info

Astro                    v4.0.9
Node                     v20.9.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap
                         @astrojs/tailwind
                         astro-robots-txt

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

The static file endpoint docs specify that only .js and .ts files can be used for creating endpoints, and indeed creating a .tsx file results in the route not being loaded.

If I want to use JSX in this route, this means I have to create a separate .tsx file and import that from my .ts file which is annoying.

If there is no specific technical reason why only .ts files are allowed, then we should also allow .tsx files.

For reference, I'm using satori which accepts JSX elements.

What's the expected result?

Adding a .tsx file that contains an endpoint should work.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-dclnmg?file=src%2Fpages%2Ftest.json.ts

Participation

  • I am willing to submit a pull request for this issue.

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