Skip to content

Conversation

@RobinMalfait
Copy link
Member

This PR adds a main and browser field for the @tailwindcss/browser package.

In the package, we do have the exports field setup, which is an alternative to the main field according to the docs:

The "exports" provides a modern alternative to "main" …

https://docs.npmjs.com/cli/v10/configuring-npm/package-json?v=true#exports

However, if you look at the unpkg link: https://unpkg.com/@tailwindcss/browser, it tries to load the index.js file. This is probably a bug in the unpkg resolver.

That said, if you look at other CDNs such as esm.sh, it does resolve correctly: https://esm.sh/@tailwindcss/browser

According to the npm docs:

If main is not set, it defaults to index.js in the package's root folder.

https://docs.npmjs.com/cli/v10/configuring-npm/package-json?v=true#main

This explains why unpkg is trying to load the index.js file.

Additionally, the npm docs also mention the browser field:

If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren't available in Node.js modules. (e.g. window)

https://docs.npmjs.com/cli/v10/configuring-npm/package-json?v=true#browser

So this PR also adds that field just to be sure.

@RobinMalfait RobinMalfait requested a review from a team as a code owner January 10, 2025 10:45
@RobinMalfait RobinMalfait enabled auto-merge (squash) January 10, 2025 11:43
@RobinMalfait RobinMalfait merged commit 5df5daa into next Jan 10, 2025
5 checks passed
@RobinMalfait RobinMalfait deleted the fix/add-missing-main branch January 10, 2025 12:39
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.

3 participants