Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/domain/core/src/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@

import { dirname } from "node:path"
import { fileURLToPath } from "node:url"
import { createRequire } from "node:module"
import { resolveNativeBinary } from "@tailwind-styled/shared"

const isBrowser = typeof window !== "undefined" || typeof document !== "undefined"
const NATIVE_UNAVAILABLE_MESSAGE =
"[tailwind-styled/core] Native binding is required but not available.\n" +
"Please ensure you have run: npm run build:rust"

// require() is safe here — tsup banner injects CJS-compatible require into ESM output.
// See tsup.config.ts esbuildOptions banner for how this is set up.
const _loadNative = (path: string): unknown => require(path)
// Use createRequire to avoid direct dynamic require() usage that breaks
// strict ESM bundlers (e.g., Next.js Turbopack module evaluation).
const _require = createRequire(import.meta.url)
const _loadNative = (path: string): unknown => _require(path)

// ─────────────────────────────────────────────────────────────────────────────
// Type Definitions
Expand Down Expand Up @@ -313,4 +315,4 @@ export function extractThemeFromCSS(cssContent: string): ThemeConfig {
}

return theme
}
}
Loading