Skip to content

Cannot build plugin: types in tailwindcss/plugin are broken #15844

@cyberalien

Description

@cyberalien

What version of Tailwind CSS are you using?

4.0.0

What build tool (or framework if it abstracts the build tool) are you using?

typescript: 5.7.2

What version of Node.js are you using?

20.14.0

What operating system are you using?

macOS 15.2

Reproduction URL

https://github.com/cyberalien/tailwind-plugin-bug

Describe your issue

Reproduction includes a very basic plugin:

import plugin from 'tailwindcss/plugin';

const exportedPlugin = plugin(() => {
	return ({ matchComponents }) => {
		matchComponents({
			test: (content: string) => {
				return {
					color: content,
				};
			},
		});
	};
});

export default exportedPlugin;

On line 3 TypeScript throws the following error:

src/plugin.ts:3:7 - error TS2742: The inferred type of 'exportedPlugin' cannot be named without a reference to '../node_modules/tailwindcss/dist/types-BTRmm49E.mjs'. This is likely not portable. A type annotation is necessary.

3 const exportedPlugin = plugin(() => {
        ~~~~~~~~~~~~~~

Building it using tsc -b.

Removed all unnecessary dependencies and packages to show smallest possible reproduction.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions