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

add SC_DISABLE_SPEEDY runtime override #2185

Merged
merged 4 commits into from Nov 11, 2018

Conversation

Projects
None yet
4 participants
@devrelm
Contributor

devrelm commented Nov 3, 2018

This is, if nothing else, a temporary fix until #2167 is resolved.

Currently, using Percy doesn't work for my company. We are using styled-components within a create-react-app app, which doesn't allow its users to override NODE_ENV for builds.

This PR allows a global SC_DISABLE_SPEEDY variable to be set before styled-components is imported. For my company, this would look something like this:

<script>SC_DISABLE_SPEEDY=/percy/.test(location.host)</script>
<script src="/main.js></script>

Related

#2038
#2089

@probablyup

This comment has been minimized.

Contributor

probablyup commented Nov 4, 2018

Needs at least one test and a changelog entry

@devrelm devrelm force-pushed the devrelm:devrelm/window.SC_DISABLE_SPEEDY branch from 6d3ccb9 to d97b41e Nov 5, 2018

@devrelm

This comment has been minimized.

Contributor

devrelm commented Nov 5, 2018

@probablyup updated with tests and changelog entry.

@devrelm devrelm force-pushed the devrelm:devrelm/window.SC_DISABLE_SPEEDY branch from d97b41e to c9d7d59 Nov 7, 2018

@devrelm

This comment has been minimized.

Contributor

devrelm commented Nov 7, 2018

Updated tests to reflect changes from #2188

@probablyup

Awesome, thank you!

@probablyup probablyup merged commit 39b7025 into styled-components:master Nov 11, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

probablyup added a commit that referenced this pull request Nov 11, 2018

add SC_DISABLE_SPEEDY runtime override (#2185)
* add SC_DISABLE_SPEEDY runtime override

* refactor SC_ATTR tests into their own 'describe' section

* add tests for DISABLE_SPEEDY and SC_DISABLE_SPEEDY global variable

* add CHANGELOG entry
@brianlenz

This comment has been minimized.

brianlenz commented Nov 11, 2018

@probablyup, any chance this PR could be backported to a v3 release? We need this exact behavior in order to get prerendering working (e.g. prerender.io). The problem right now is that we need to do prerendering on a production build, which results in component styles not being included in the DOM due to the use of CSSOM insertRule. We would set up a rule very similar to the host example here, only we'd set SC_DISABLE_SPEEDY based on the user agent (e.g. when it's for prerender). I realize you're on v4 releases now, but we've not upgraded yet, so a v3 release would be great. If you're not planning to do any further v3 releases, we'll start exploring the v4 upgrade path in anticipation of the next v4 release that includes this PR.

Thanks!

@mxstbr

This comment has been minimized.

Member

mxstbr commented Nov 11, 2018

We probably won't backport this change, so I think the best course of action would be for you to upgrade to v4.

If that's not possible for whatever reason, we'd probably merge a PR backporting this to the last v3 release!

@devrelm devrelm deleted the devrelm:devrelm/window.SC_DISABLE_SPEEDY branch Nov 12, 2018

@brianlenz

This comment has been minimized.

brianlenz commented Dec 3, 2018

Hi @mxstbr, we are attempting to upgrade to styled-components 4.1, and we're running into a bit of dependency hell trying to get all of our code and dependencies to play nice after updating (we are using TypeScript, btw). It would be immensely helpful to us if you could backport this to a v3 release so we can make use of this functionality and save the upgrade to styled-components 4 for a future day. We are currently running styled-components 3.3.3, but I'm guessing upgrading to 3.4 should be much simpler for us than upgrading to 4.1.

Thanks for considering it!

@mxstbr

This comment has been minimized.

Member

mxstbr commented Dec 3, 2018

Hey, feel free to create a v3 branch off the latest commit that's in v3 and submitting a PR against it that integrates this feature, we'd probably publish a new release if it works as intended!

@brianlenz

This comment has been minimized.

brianlenz commented Dec 3, 2018

Thanks, we'll do that!

platypusrex added a commit to platypusrex/styled-components that referenced this pull request Dec 4, 2018

add SC_DISABLE_SPEEDY runtime override (styled-components#2185)
* add SC_DISABLE_SPEEDY runtime override

* refactor SC_ATTR tests into their own 'describe' section

* add tests for DISABLE_SPEEDY and SC_DISABLE_SPEEDY global variable

* add CHANGELOG entry

# Conflicts:
#	CHANGELOG.md
#	src/constants.js
#	src/test/constants.test.js

brianlenz pushed a commit to NarrativeCompany/styled-components that referenced this pull request Dec 5, 2018

add SC_DISABLE_SPEEDY runtime override (styled-components#2185)
* add SC_DISABLE_SPEEDY runtime override

* refactor SC_ATTR tests into their own 'describe' section

* add tests for DISABLE_SPEEDY and SC_DISABLE_SPEEDY global variable

* add CHANGELOG entry

# Conflicts:
#	CHANGELOG.md
#	src/constants.js
#	src/test/constants.test.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment