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

order of bindings and styled nodes #2

Closed
Mokshit06 opened this issue Jun 12, 2022 · 1 comment
Closed

order of bindings and styled nodes #2

Mokshit06 opened this issue Jun 12, 2022 · 1 comment

Comments

@Mokshit06
Copy link
Member

The current published version of macaron pushes all the bindings first and the styled nodes later, this means that all the nodes that reference a style declaration in the beginning of the new virtual file and the styled nodes are later.
This works fine if only the variables are being used inside declaration but becomes an issue when the declaration is used inside a another variable since babel considers both to be a "binding"

Consider this:

const color = 'red';
const red = style({ color });
const entireClass = `pt-2 ${red}`;

the expected compiled output would be

const color = 'red';
const red = 'red_HASH';
const entireClass = `pt-2 ${red}`;

but it is actually

const color = 'red';
const entireClass = `pt-2 ${red}`;

const red = 'red_HASH';

This would produce an error and shouldn't be that hard to fix. I think the fix would require checking the source location of binding and declaration and based on that decide which one should be pushed first

@Mokshit06
Copy link
Member Author

Should be fixed with 4adc575

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

No branches or pull requests

1 participant