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

Fix esternal styles with expressions are not transpiled #223

Merged
merged 1 commit into from
Jun 4, 2017

Conversation

giuseppeg
Copy link
Collaborator

@giuseppeg giuseppeg commented Jun 4, 2017

The problem was that when using interpolation in external files eg. div { color: ${colors.foo} } we replace the interpolation ${colors.foo} with a placeholder so that it can be parsed as css.

For external files we also check whether the export is a string or rather valid css (we do css detection). The problem was that the placeholder is invalid css eg. div { color: %foo% } } (%foo% is not a valid value for color) so we skipped the file altogether.

I fixed it by using a fake css custom property as placeholder instead.

Fixes #215 #220 #219 (the last two are fixed because of the stylis version bump)

The problem was that when using interpolation in external files eg. `div { color: ${colors.foo} }` we replace the interpolation `${colors.foo}` with a placeholder so that it can be parsed as css.

For external files we also check whether the export is a string or rather valid css (we do css detection). The problem was that the placeholder is invalid css eg. `div { color: %foo% } }` (`%foo%` is not a valid value for color) so we skipped the file altogether.

I fixed it by using a fake css custom property as placeholder instead.
@giuseppeg giuseppeg requested review from rauchg and nkzawa June 4, 2017 09:59
@giuseppeg giuseppeg merged commit c81c95e into master Jun 4, 2017
@giuseppeg giuseppeg deleted the fix-expressions-in-externals-styles branch June 4, 2017 10:13
giuseppeg added a commit that referenced this pull request Jun 10, 2017
)

#223 fixed only one case, this branch aims to fix them all :)

Our safeguard is the `t.regex` from "transpiles external stylesheets with validation (expressions)" in `tests/external.js`, if that matches then the files are parsed correctly as css and therefore processed by styled-jsx.

Fixes #224
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 this pull request may close these issues.

Can't keep styles for more than one component in separate files: it breaks
2 participants