Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@tailwindcss/line-clamp check produces an error if bundled. #10894

Closed
mayerraphael opened this issue Mar 29, 2023 · 6 comments · Fixed by #10915
Closed

@tailwindcss/line-clamp check produces an error if bundled. #10894

mayerraphael opened this issue Mar 29, 2023 · 6 comments · Fixed by #10915
Assignees

Comments

@mayerraphael
Copy link

mayerraphael commented Mar 29, 2023

https://github.com/tailwindlabs/tailwindcss/blame/3809127a2ce7e8173611ae40c7a260bb56e6342f/src/util/normalizeConfig.js#L304

We use tailwind with StencilJS, which uses Rollup to generate packages. The problem with this change is that the require call is moved out of the check farther up. Now this require call is called outside the try catch and fails the whole application. Most bundlers optimize imports, especially if they have to resolve interoparability between ESM and CJS.

This is also the only require call of the whole file, the other imports use ESM.

@mayerraphael mayerraphael changed the title Bundler rewrite require calls, producing an error. @tailwindcss/line-clamp produces an error if bundled. Mar 29, 2023
@mayerraphael mayerraphael changed the title @tailwindcss/line-clamp produces an error if bundled. @tailwindcss/line-clamp check produces an error if bundled. Mar 29, 2023
@herrlegno
Copy link

I got this problem too after upgrading to v3.3.0:
image

@fireworks2005
Copy link

I got the same error after upgraded to v3.3.0

@RobinMalfait RobinMalfait self-assigned this Mar 29, 2023
@RobinMalfait
Copy link
Member

Hey, thank you for this bug report! 🙏

Can you provide a minimal reproduction repo that showcases this issue?

It's also very odd that tools like rollup modify the intentional source code and create bugs like that 🤔. Either way, if you can provide a reproduction than I am happy to take a look for you!

@haleksandre
Copy link

haleksandre commented Mar 29, 2023

Here's a reproduction repo

https://github.com/haleksandre/sveltekit-tailwind

It looks like the problems occur when you use Tailwind's 'non-ESM' module such as tailwindcss/resolveConfig.js within an 'ESM' project. Since they aren't 'compatible' you need to use a third-party plugin to 'convert' tailwind's 'non-ESM' to an 'ESM' otherwise you'll have a require() doesn't exist error. These plugins such as viteCommonjs in the reproduction repo seem to look through the entire codebase for require() & hoist them at the top as an import. In this case, looks like it finds the require('@tailwindcss/line-clamp') mentioned above at:https://github.com/tailwindlabs/tailwindcss/blame/3809127a2ce7e8173611ae40c7a260bb56e6342f/src/util/normalizeConfig.js#L304. Now the problem becomes that if the package isn't installed, it will break the app as the import will fail with a module not found error.

The workaround is to install the now obsolete @tailwindcss/line-clamp to satisfy the import & the hoisted import won't break things.

@sgarcia-dev
Copy link

sgarcia-dev commented Mar 30, 2023

It's also very odd that tools like rollup modify the intentional source code and create bugs like that 🤔. Either way, if you can provide a reproduction than I am happy to take a look for you!

We encountered the same issue as well with webpack 5.77.0. Kinda curious though, could this be related to a process is not defined issue we encountered as well? I filed a bug here. We are also mixing ESM + Common JS modules.
#10918

We're rolling back to v3.2.7 for now since that resolves all these issues for now.

@reinink
Copy link
Member

reinink commented Mar 30, 2023

Hey thanks again for reporting this. This has been fixed in #10919 and will be released as part of v3.3.1. Let us know if you have any further issues 👍

@reinink reinink closed this as completed Mar 30, 2023
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 a pull request may close this issue.

7 participants