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

Falsy values in tailwind config trigger class not found #41

Closed
vincent-vieira opened this issue Apr 17, 2020 · 7 comments
Closed

Falsy values in tailwind config trigger class not found #41

vincent-vieira opened this issue Apr 17, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@vincent-vieira
Copy link

Hello there,

First of all, thanks for this library. Even though it's still young, it is showing promising things and I'm eager to see future releases !

I'm posting due to a weird issue I'm encountering on my GatsbyJS project.
I have setup a project as stated in the docs, and am using Twin with Emotion.

I've customized the "inset" section of my Tailwind theme as is :
inset: { '0': 0, auto: 'auto', 'icon-offset': '19px', }

From time to time, I don't know why it doesn't always occur, I'm getting this error message and my bundle no longer builds :

Generating development JavaScript bundle failed
<hidden location>/frontend/src/mixins/Forms.ts:

✕ inset-y-0 was not found
Did you mean inset-y-0?

File: src/mixins/Forms.ts

I've tried restarting the dev server, clearing the .cache folder inside node_modules, nothing helps. I can sometimes get rid of the error by removing all inset classes from the incriminated file and let livereloading do its job.

Any ideas why this happens ?
Let me know if I can help you with anything by providing you any specific details.

@ben-rogerson
Copy link
Owner

ben-rogerson commented Apr 18, 2020

Great to hear you're enjoying twin! - Aside from the bug you've found anyway 😄

I haven't seen this specific bug before but I am aware of some caching issues, particularly in Gatsby.

I've made a codesandbox attempting to reproduce the issue but haven't succeeded yet.

Perhaps you could verify the tailwind.config.js is the same? Or if there's any other plugins that could be interfering.

Also another thought - is the error still showing after you do a gatsby build?

@vincent-vieira
Copy link
Author

vincent-vieira commented Apr 20, 2020

I debugged a little, and got the issue.

The inset config for zero value should be '0': '0', not '0': 0. Otherwise, the lookup here will fail as the '0' config value as a number, extracted from the classParts will be evaluated as a falsy value... And because the lookup fails, the resolve function returns an empty object triggering the error even if the class exists in the Tailwind configuration.

This was this dumb lol.

I'll let you close the issue if you don't think it is necessary to add any safeguard 😊

@ben-rogerson
Copy link
Owner

Hey Vincent, thanks for looking into this and it's great you got to the bottom of it.
I think adding a value of 0 should be allowed so I'll add a fix for this 👍

Were you able to trigger the error consistently?

@vincent-vieira
Copy link
Author

Apart from cache issues, yes !
Everytime I switch back from '0' or '0px' to 0 while clearing node_modules/.cache folder and restarting Gatsby server (due to config livereloading issues), the error comes back.

@ben-rogerson
Copy link
Owner

great, that'll help me out testing a fix - thanks so much for submitting the issue :)

@ben-rogerson ben-rogerson added the bug Something isn't working label Apr 20, 2020
@ben-rogerson ben-rogerson changed the title Tailwind class is marked as not found even though it is Falsy values in tailwind config trigger class not found Apr 20, 2020
@vincent-vieira
Copy link
Author

If I can help you testing your fix, don't hesitate to sollicitate me :)

@ben-rogerson
Copy link
Owner

This bug was fixed in v1.0.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants