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

Compatibility with macros (or any erased-at-compile-time symbol) #15

Open
itsMapleLeaf opened this issue Jul 5, 2020 · 1 comment
Open

Comments

@itsMapleLeaf
Copy link

I integrated twin.macro into my svelte project, and everything works as expected, but after making any change, HMR always errors out with "ReferenceError: tw is not defined".

Here's a reproduction repo. Run yarn dev, then make any change in the template, and the error will show up.

The parts of the code using tw, in and out of the template, are replaced with a JS object of the corresponding tailwind styles, but HMR (or something else?) is capturing tw as if it's a reactive component variable, as seen in the compiled output:

  $$self.$capture_state = () => ({
    css: _emotion_css__WEBPACK_IMPORTED_MODULE_1__["css"],
    tw,
    bigText
  });

I'm not sure what would be the best way around this 🤔 I can provide any additional details as needed

@rixo
Copy link
Collaborator

rixo commented Jul 5, 2020

Thanks for the very nice report.

Yes indeed, $capture_state is too greedy, it shouldn't capture imports. This is something that needs to be fixed in Svelte. I'm going to see if I can do something.

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

2 participants