Skip to content

fix: exclude @tailwindcss/oxide from dep optimization#850

Merged
james-elicx merged 1 commit intocloudflare:mainfrom
467469274:feat/add-missing-shims-and-fixes
Apr 16, 2026
Merged

fix: exclude @tailwindcss/oxide from dep optimization#850
james-elicx merged 1 commit intocloudflare:mainfrom
467469274:feat/add-missing-shims-and-fixes

Conversation

@467469274
Copy link
Copy Markdown
Contributor

@467469274 467469274 commented Apr 15, 2026

Summary

Exclude @tailwindcss/oxide from Vite's dependency optimization — Rolldown cannot process native .node binaries.

Problem

Rolldown cannot process native .node binary files. When a project uses Tailwind CSS v4, @tailwindcss/oxide contains platform-specific native bindings (tailwindcss-oxide.darwin-arm64.node) that cause Rolldown to fail with UNLOADABLE_DEPENDENCY during dependency optimization.

Error:

[UNLOADABLE_DEPENDENCY] Error: Could not load @tailwindcss/oxide-darwin-arm64/tailwindcss-oxide.darwin-arm64.node
  stream did not contain valid UTF-8

Fix

Added @tailwindcss/oxide to the default optimizeDeps.exclude list alongside vinext and @vercel/og.

Changes

Dropped the next/navigation default export per review feedback — Next.js itself does not provide a default export from next/navigation, and the stated @clerk/nextjs use case was incorrect (Clerk uses named imports).

Test plan

  • Reproduced with Vite 8.0.8 + Rolldown 1.0.0-rc.15 + @tailwindcss/vite 4.2.2
  • Tested against next-shadcn-dashboard-starter (Next.js 16, Tailwind v4)
  • Run existing test suite

🤖 Generated with Claude Code

@james-elicx
Copy link
Copy Markdown
Collaborator

/bigbonk review

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 16, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@850

commit: f9b0c68

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

The @tailwindcss/oxide exclusion is a legitimate fix — Rolldown cannot process native .node binaries and this correctly prevents the UNLOADABLE_DEPENDENCY error during dep optimization.

However, the next/navigation default export should not be merged. It diverges from real Next.js behavior and the stated justification does not hold up under investigation.

@tailwindcss/oxide exclusion — Approve

This is correct. @tailwindcss/oxide contains platform-specific native .node binaries that Rolldown cannot bundle. Excluding it from optimizeDeps is the right fix, consistent with how @vercel/og is already excluded for similar reasons.

next/navigation default export — Request changes

Next.js does not provide a default export from next/navigation. The source at packages/next/src/client/components/navigation.ts contains only named exports. The type declaration (next/navigation.d.ts) does export * from ... with no default. The CJS interop block in the compiled output is a no-op because exports.default is undefined.

@clerk/nextjs does not use a default import from next/navigation. Every import in Clerk's source is a named import (import { useRouter } from 'next/navigation', etc.). The one CJS require('next/navigation').usePathname usage accesses a named property on the module object, not a default export.

Adding a default export that Next.js itself doesn't have:

  1. Creates a behavioral divergence — code using import nav from 'next/navigation' would work on vinext but fail on real Next.js
  2. Could mask bugs in user code or libraries (imports that work on vinext but break when deployed to actual Next.js)
  3. The react-server variant (navigation.react-server.ts) doesn't get the default export, so there's an inconsistency between environments

If there's a specific library that genuinely needs this, please share the import site so we can investigate the root cause. It's more likely a CJS/ESM interop issue that should be fixed differently (e.g., in the module resolution layer).

Recommendation: Split this PR — land the @tailwindcss/oxide fix (it's correct and useful) and drop the default export (or open a separate issue with reproduction steps showing which library actually fails).

Comment thread packages/vinext/src/shims/navigation.ts Outdated
Comment on lines +1526 to +1540
// Default export for `import navigation from 'next/navigation'` compatibility.
// Some third-party libraries use default import instead of named imports.
export default {
useRouter,
usePathname,
useSearchParams,
useParams,
useSelectedLayoutSegment,
useSelectedLayoutSegments,
redirect,
permanentRedirect,
notFound,
forbidden,
unauthorized,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default export should be removed. next/navigation in Next.js does not have a default export — the source at packages/next/src/client/components/navigation.ts contains only named exports, and the type declaration does export * with no default.

The PR description mentions @clerk/nextjs as the motivating library, but Clerk only uses named imports (import { useRouter } from 'next/navigation'). Its one CJS usage (require('next/navigation').usePathname) accesses a named property, not a default.

Adding a default export that doesn't exist in real Next.js:

  • Allows code that would break on real Next.js to silently work on vinext
  • Is inconsistent with the react-server variant of this shim (which doesn't get the default export)
  • Doesn't actually fix a known compatibility issue

If there's a specific library failing with The requested module does not provide an export named 'default', it's more likely a CJS/ESM interop issue in Vite's module resolution that should be addressed there rather than by adding a fake default export.

viteConfig.optimizeDeps = {
exclude: [...new Set([...incomingExclude, "vinext", "@vercel/og"])],
// @tailwindcss/oxide contains native .node bindings that Rolldown cannot process
exclude: [...new Set([...incomingExclude, "vinext", "@vercel/og", "@tailwindcss/oxide"])],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This exclusion is correct. Native .node binaries can't be processed by Rolldown's bundler. Good fix.

Minor thought: tailwindcss itself (v4) also depends on lightningcss, which has its own native bindings. If users hit a similar error from lightningcss, it may need the same treatment. Not blocking — just something to watch for.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 16, 2026

Review posted. Here's a summary of my findings:

@tailwindcss/oxide exclusion (index.ts) -- Approved. Rolldown genuinely cannot process native .node binaries, and this is the correct fix, consistent with how @vercel/og is already handled.

next/navigation default export (navigation.ts) -- Requested changes. After investigating:

  1. Next.js itself does not have a default export from next/navigation -- the source only contains named exports.
  2. @clerk/nextjs does not use a default import -- every import from next/navigation in Clerk's source is a named import. The CJS require('next/navigation').usePathname is a property access on the module object, not a default import.
  3. The react-server variant of the navigation shim doesn't get the default export, creating an environment inconsistency.
  4. Adding a default export that doesn't exist in real Next.js would mask bugs in user code.

I recommended splitting the PR: land the oxide fix and either drop or separately investigate the default export with a concrete reproduction case.

github run

Rolldown cannot process native `.node` binary files. When a project uses
Tailwind CSS v4, the `@tailwindcss/oxide` package contains platform-specific
native bindings (`tailwindcss-oxide.darwin-arm64.node`) that cause Rolldown
to fail with `UNLOADABLE_DEPENDENCY` during dependency optimization.

Added `@tailwindcss/oxide` to the default `optimizeDeps.exclude` list
alongside `vinext` and `@vercel/og`.

Error reproduced with:
- Vite 8.0.8 + Rolldown 1.0.0-rc.15
- Any project with @tailwindcss/vite or @tailwindcss/postcss installed
- Tested against next-shadcn-dashboard-starter (Next.js 16, Tailwind v4)
@467469274 467469274 force-pushed the feat/add-missing-shims-and-fixes branch from 6c9e244 to f9b0c68 Compare April 16, 2026 06:50
@467469274 467469274 changed the title fix: exclude @tailwindcss/oxide from dep optimization + add navigation default export fix: exclude @tailwindcss/oxide from dep optimization Apr 16, 2026
@james-elicx
Copy link
Copy Markdown
Collaborator

/bigbonk review

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The PR is now a clean single-purpose fix — @tailwindcss/oxide excluded from dep optimization because Rolldown can't process native .node binaries. The next/navigation default export was correctly dropped per the previous review.

The change is minimal, correct, and consistent with the existing @vercel/og exclusion.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 16, 2026

Approved. The PR is a clean, single-purpose fix that adds @tailwindcss/oxide to the optimizeDeps.exclude list. The next/navigation default export was correctly dropped per the prior review, leaving only the legitimate native binary exclusion.

github run

@james-elicx james-elicx enabled auto-merge (squash) April 16, 2026 07:10
@james-elicx james-elicx merged commit 672da73 into cloudflare:main Apr 16, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants