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

Dynamic nested groups names webpack error #10266

Closed
bstivenprz opened this issue Jan 7, 2023 · 5 comments · Fixed by #10276
Closed

Dynamic nested groups names webpack error #10266

bstivenprz opened this issue Jan 7, 2023 · 5 comments · Fixed by #10276
Assignees

Comments

@bstivenprz
Copy link

What version of Tailwind CSS are you using?

I'm using the latest v3.2.4

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

I'm using Next.js (v13.1.1) with Webpack (v5.74.0)

What version of Node.js are you using?

v18.12.1

What browser are you using?

Chrome

What operating system are you using?

Windows

Reproduction URL

CodeSandbox bug repoduction

Describe your issue

I tried to assign names to groups by props dynamically on runtime but it failed to compile with this message:

./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[3].oneOf[11].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[3].oneOf[11].use[2]!./styles/globals.css TypeError: Cannot read properties of undefined (reading '5') at resolveMatches.next (<anonymous>) at Function.from (<anonymous>) at runMicrotasks (<anonymous>)

When i concatenate the id prop to a group with + operator this error don't come up but nested group doesn't work. I tried every plugin out there but nothing worked naming groups dynamically by props.

@adamwathan
Copy link
Member

Hey! You can’t use concatenation or interpolation to create class names, as Tailwind generates all of your styles at build time and needs to be able to statically extract every class you’re using from your templates:

https://tailwindcss.com/docs/content-configuration#dynamic-class-names

It shouldn’t cause the build to fail or crash though, so will definitely look into that.

@adamwathan
Copy link
Member

Here's a super minimal reproduction that triggers the error even in Play:

https://play.tailwindcss.com/s8ydiMPxcN

@bstivenprz
Copy link
Author

Hey! Thanks for that information, i do a little change and it's working now.

@adamwathan adamwathan reopened this Jan 8, 2023
@adamwathan
Copy link
Member

Going to keep this open so we can diagnose the crash 👍🏻

@thecrypticace
Copy link
Contributor

This was partially fixed in the insiders build already as we now skip rules with unparsable selectors. But this shouldn't have been unparsable. We weren't escaping things when we needed to nor handling those escapes properly. Both of which we now do!

I've merged the fix for this in #10276 and it'll be available in our next release. In the meantime you can test it with our insiders build which should be available in a few minutes: npm install tailwindcss@insiders

Thanks for reporting this!

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.

3 participants