Skip to content

Cloudflare Vite Workerd dev fails when importing @akin01/solid-email server-side #12

Description

@Akin01

Summary

Importing @akin01/solid-email from server-side code that runs under Cloudflare Vite dev / Workerd currently fails during SSR route loading. The package root appears to pull transitive dependencies that either evaluate through CJS require in Workerd or get optimized into a bundle that cannot resolve Tailwind's ../data/patch.json.

A Workerd-safe server entrypoint would make the package usable in Cloudflare Worker SSR apps.

Environment

Observed in an app using:

  • @akin01/solid-email@0.1.4
  • @solid-email/render@0.1.4
  • solid-js@1.9.13
  • vite@8.0.16
  • vite-plugin-solid@2.11.12
  • @cloudflare/vite-plugin@1.39.2
  • miniflare@4.20260601.0
  • @tanstack/solid-start@1.168.19
  • Node 25.x

pnpm view @akin01/solid-email@0.1.4 exports currently shows only:

{
  ".": { import: { types: "./dist/index.d.mts", default: "./dist/index.mjs" }, require: { types: "./dist/index.d.cts", default: "./dist/index.cjs" } },
  "./client": { import: { types: "./dist/client/index.d.mts", default: "./dist/client/index.mjs" }, require: { types: "./dist/client/index.d.cts", default: "./dist/client/index.cjs" } }
}

There is no published ./server subpath.

Minimal repro shape

In a Cloudflare Vite / SolidStart app, import the package root from a module that is loaded by the server route graph:

import { Button } from "@akin01/solid-email";
import { Slot, compileSync } from "@solid-email/render";

const template = compileSync(
  () => (
    <Button href="https://example.com">
      <Slot name="label" />
    </Button>
  ),
  { withPlainText: true },
);

export function renderEmail() {
  return template.renderSync({ label: "Open" });
}

Then run Cloudflare Vite dev and request a page that loads the server route graph:

pnpm dev
curl http://localhost:3000/

Observed failures

With normal SSR config / targeted noExternal, the request fails with:

ReferenceError: require is not defined
    at runInRunnerObject (workers/runner-worker/index.js:107:3)
    at async Promise.all (index 0)
    at loadEntries (.../@tanstack/start-server-core/src/createStartHandler.ts:115:53)
    at startRequestResolver (.../@tanstack/start-server-core/src/createStartHandler.ts:418:23)

With broader bundling attempts such as ssr.noExternal: true, the earlier dependency optimizer failure appears instead:

AssertionError [ERR_ASSERTION]: Unexpected error: no match for module: ../data/patch.json.
Fallback service failed to fetch module ...
spec = /?specifier=.../apps/web/node_modules/.vite/data/patch.json&referrer=.../apps/web/node_modules/.vite/deps_ssr/%40akin01_solid-email.js&rawSpecifier=..%2Fdata%2Fpatch.json
Error: No such module ".../apps/web/node_modules/.vite/data/patch.json".

Expected behavior

Server-side email components should be importable in Workerd/Cloudflare Worker SSR without:

  • runtime CJS require
  • optimizer references to missing Tailwind package data files
  • needing to import the browser/client entrypoint

Requested fix

Please consider publishing a Workerd-safe server entrypoint, for example:

import { Button, Html, Body, Container, Text } from "@akin01/solid-email/server";

Ideally that server entrypoint would:

  • use ESM only for Workerd/browser-worker conditions
  • avoid top-level imports of optional/heavy features such as Tailwind, Prism, Marked, and CSS Tree unless their components are imported
  • expose package exports conditions for workerd, worker, and/or browser where appropriate
  • keep @akin01/solid-email/client for DOM preview/client rendering

Current workaround

The app can keep @solid-email/render compiled templates working by avoiding a runtime import of @akin01/solid-email in the Worker route graph. This means using local JSX for email markup, or only type-level references to @akin01/solid-email, but that loses direct use of the component package at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions