Skip to content

Importing cloudflare:workers breaks the client bundle when it's imported on a dependency of a server function #7199

@masylum

Description

@masylum

Which project does this relate to?

Start

Describe the bug

Similar to this bug report, but it happens without middlewares.

Your Example Website or App

I don't have it

Steps to Reproduce the Bug or Issue

  • I have a foo.functions.ts file that imports auth.ts
  • I have an auth.ts file with import { env } from "cloudflare:workers"

It explodes trying to add cloudflare:workers into the client bundle.

If I move the import { env } from "cloudflare:workers" into foo.functions.ts file and pass it as a dependency (my current fix), then it works.

So it looks like the tree shacking or whatever mechanism is used to clean server functions for client bundles, only works at 1 level depth.

Expected behavior

Not to blow up

Screenshots or Videos

No response

Platform

@cloudflare/vite-plugin 1.32.2
@tanstack/react-router 1.168.10
@tanstack/react-start 1.167.16
vite 8.0.0

Additional context

No response

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