@tailwindcss/node: dist/index.d.ts imports ./ast, ./candidate and five more modules the package does not ship
What version of Tailwind CSS are you using?
v4.3.3, and main at 8cc0551 (@tailwindcss/[email protected])
What build tool (or framework if it abstracts the build tool) are you using?
None: @tailwindcss/node imported directly, type-checked with TypeScript 7.0.2
What version of Node.js are you using?
v26.12.1
What browser are you using?
N/A
What operating system are you using?
Windows
Reproduction URL
https://github.com/YevheniiKotyrlo/tailwindcss-node-declarations
Describe your issue
@tailwindcss/node's dist/index.d.ts and dist/index.d.mts start with seven imports of modules the package does not ship:
import { AstNode as AstNode$1 } from './ast';
import { Candidate, Variant } from './candidate';
import { compileAstNodes } from './compile';
import { ClassEntry, VariantEntry, CanonicalizeOptions } from './intellisense';
import { Theme } from './theme';
import { Utilities } from './utilities';
import { Variants } from './variants';
dist/ holds no ast, candidate, compile, intellisense, theme, utilities or variants declarations, so a project that type-checks its dependencies' declarations (skipLibCheck: false) cannot import @tailwindcss/node without these errors. They look like tailwindcss's internal src/ modules: src/compile.ts and src/urls.ts import types from ../../tailwindcss/src/ast, outside the package, and the declaration bundle keeps those paths as relative imports.
Steps:
- Clone the reproduction and run
npm install. It installs@tailwindcss/nodeandtailwindcssat0.0.0-insiders.8cc0551, TypeScript 7.0.2 and@types/node26.6.5. - Run
npm run check, which type-checksindex.ts(import { compile } from '@tailwindcss/node', then acompile()and abuild()) withstrict: true,skipLibCheck: falseandmodule/moduleResolutionnodenext. - Run
npm start, which runs the sameindex.tswith Node.
Expected: step 2 reports no errors.
Seen: step 2 reports seven TS2307 errors, below; step 3 prints true, so only the declarations are affected. 4.3.3's dist/index.d.ts starts with the same seven imports.
node_modules/@tailwindcss/node/dist/index.d.ts(1,38): error TS2307: Cannot find module './ast' or its corresponding type declarations.
node_modules/@tailwindcss/node/dist/index.d.ts(2,36): error TS2307: Cannot find module './candidate' or its corresponding type declarations.
node_modules/@tailwindcss/node/dist/index.d.ts(3,33): error TS2307: Cannot find module './compile' or its corresponding type declarations.
node_modules/@tailwindcss/node/dist/index.d.ts(4,63): error TS2307: Cannot find module './intellisense' or its corresponding type declarations.
node_modules/@tailwindcss/node/dist/index.d.ts(5,23): error TS2307: Cannot find module './theme' or its corresponding type declarations.
node_modules/@tailwindcss/node/dist/index.d.ts(6,27): error TS2307: Cannot find module './utilities' or its corresponding type declarations.
node_modules/@tailwindcss/node/dist/index.d.ts(7,26): error TS2307: Cannot find module './variants' or its corresponding type declarations.
I'd like to take a look at this and open a PR. I'll start by reproducing it with the linked repo and checking the dts setup in packages/@tailwindcss-node/tsup.config.ts.
This is the patch I apply locally for this:
diff --git a/dist/index.d.ts b/dist/index.d.ts
index 23a898bf2f9e4aedeb4a3e921f45294b1348d657..20254429f4a257f5ac58411286698c8343797bd3 100644
--- a/dist/index.d.ts
+++ b/dist/index.d.ts
@@ -1,10 +1,14 @@
-import { AstNode as AstNode$1 } from './ast';
-import { Candidate, Variant } from './candidate';
-import { compileAstNodes } from './compile';
-import { ClassEntry, VariantEntry, CanonicalizeOptions } from './intellisense';
-import { Theme } from './theme';
-import { Utilities } from './utilities';
-import { Variants } from './variants';
+// tailwindcss's internal modules these types come from are not shipped, so the design system's internals stay opaque: https://github.com/tailwindlabs/tailwindcss/issues/20631
+type AstNode$1 = unknown;
+type Candidate = unknown;
+type Variant = unknown;
+type ClassEntry = unknown;
+type VariantEntry = unknown;
+type CanonicalizeOptions = unknown;
+type Theme = unknown;
+type Utilities = unknown;
+type Variants = unknown;
+declare function compileAstNodes(...parameters: readonly unknown[]): unknown;
import * as tailwindcss from 'tailwindcss';
import { Polyfills, Features } from 'tailwindcss';
export { Features, Polyfills } from 'tailwindcss';
I'm happy to open a PR with it if that helps.
The declarations of @tailwindcss/node imported ./ast, ./candidate and five more internal modules of tailwindcss, so tsc with skipLibCheck: false reported seven TS2307 errors. Now dist/index.d.ts imports these types only from tailwindcss, so your npm run check passes without the local patch.
This should be fixed by https://github.com/tailwindlabs/tailwindcss/pull/20632, and will be available in the next release.
You can already try it with the insiders build. It is published a few minutes after the merge:
npm install tailwindcss@insiders @tailwindcss/node@insiders
Sent by an AI assistant on behalf of @RobinMalfait.