fix: exclude @tailwindcss/oxide from dep optimization#850
Conversation
|
/bigbonk review |
commit: |
There was a problem hiding this comment.
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:
- Creates a behavioral divergence — code using
import nav from 'next/navigation'would work on vinext but fail on real Next.js - Could mask bugs in user code or libraries (imports that work on vinext but break when deployed to actual Next.js)
- The
react-servervariant (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).
| // 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, | ||
| }; |
There was a problem hiding this comment.
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-servervariant 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"])], |
There was a problem hiding this comment.
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.
|
Review posted. Here's a summary of my findings:
I recommended splitting the PR: land the oxide fix and either drop or separately investigate the default export with a concrete reproduction case. |
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)
6c9e244 to
f9b0c68
Compare
|
/bigbonk review |
There was a problem hiding this comment.
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.
|
Approved. The PR is a clean, single-purpose fix that adds |
Summary
Exclude
@tailwindcss/oxidefrom Vite's dependency optimization — Rolldown cannot process native.nodebinaries.Problem
Rolldown cannot process native
.nodebinary files. When a project uses Tailwind CSS v4,@tailwindcss/oxidecontains platform-specific native bindings (tailwindcss-oxide.darwin-arm64.node) that cause Rolldown to fail withUNLOADABLE_DEPENDENCYduring dependency optimization.Error:
Fix
Added
@tailwindcss/oxideto the defaultoptimizeDeps.excludelist alongsidevinextand@vercel/og.Changes
Dropped the
next/navigationdefault export per review feedback — Next.js itself does not provide a default export fromnext/navigation, and the stated@clerk/nextjsuse case was incorrect (Clerk uses named imports).Test plan
🤖 Generated with Claude Code