Skip to content

Commit 0685b61

Browse files
authored
Upgrade dependencies and remove styled-components workarounds (#39)
* Upgrade dependencies * Remove styled-components workarounds With v5 they're not necessary anymore. * Remove styled-components note from README
1 parent e9b61ee commit 0685b61

File tree

7 files changed

+902
-1077
lines changed

7 files changed

+902
-1077
lines changed

README.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,6 @@ already, `ssrPrepass` will suspend on `<Query>` components.
137137

138138
[More information can be found in Apollo's own docs](https://www.apollographql.com/docs/react/features/server-side-rendering.html#getDataFromTree)
139139

140-
## Optional Dependencies
141-
142-
### Special case for `styled-components`
143-
144-
`react-ssr-prepass` has an optional dependency on `styled-components@>=4.0.0`.
145-
This optimization skips any styling logic and imitates the attributes and props
146-
logic of `styled-components` otherwise.
147-
148-
It exists because styled-components may populate the `ServerStyleSheet` as
149-
part of a `react-ssr-prepass` run, since it behaves like a normal React renderer.
150-
This is dangerous if the element tree that is passed to `react-ssr-prepass`
151-
is not wrapped in a `ServerStyleSheet` at all, since it will start accumulating
152-
styles and cause a memory leak. In `v4` it can also cause these styles to
153-
become _global_ and be sent to every server-rendered page.
154-
155-
If you're not using styled-components however and are bundling your server-side
156-
code you need to stub styled-components with an empty package or just install it.
157-
158140
## Prior Art
159141

160142
This library is (luckily) not a reimplementation from scratch of

package.json

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,33 @@
6060
"react-is": "^16.8.0"
6161
},
6262
"dependencies": {
63-
"object-is": "^1.0.1"
63+
"object-is": "^1.0.2"
6464
},
6565
"devDependencies": {
66-
"@babel/core": "^7.5.5",
67-
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
68-
"@babel/plugin-transform-object-assign": "^7.2.0",
69-
"@babel/preset-env": "^7.5.5",
70-
"@babel/preset-flow": "^7.0.0",
71-
"@babel/preset-react": "^7.0.0",
66+
"@babel/core": "^7.8.3",
67+
"@babel/plugin-transform-flow-strip-types": "^7.8.3",
68+
"@babel/plugin-transform-object-assign": "^7.8.3",
69+
"@babel/preset-env": "^7.8.3",
70+
"@babel/preset-flow": "^7.8.3",
71+
"@babel/preset-react": "^7.8.3",
7272
"babel-plugin-closure-elimination": "^1.3.0",
73-
"babel-plugin-transform-async-to-promises": "^0.8.14",
74-
"codecov": "^3.5.0",
75-
"flow-bin": "^0.106.3",
76-
"husky": "^3.0.5",
73+
"babel-plugin-transform-async-to-promises": "^0.8.15",
74+
"codecov": "^3.6.1",
75+
"flow-bin": "^0.116.1",
76+
"husky": "^4.0.10",
7777
"jest": "^24.9.0",
78-
"lint-staged": "^9.2.5",
78+
"lint-staged": "^9.5.0",
7979
"npm-run-all": "^4.1.5",
80-
"prettier": "^1.18.2",
81-
"react": "^16.9.0",
82-
"react-dom": "^16.9.0",
83-
"react-is": "^16.9.0",
84-
"rollup": "^1.20.3",
80+
"prettier": "^1.19.1",
81+
"react": "^16.12.0",
82+
"react-dom": "^16.12.0",
83+
"react-is": "^16.12.0",
84+
"rollup": "^1.29.0",
8585
"rollup-plugin-babel": "^4.3.3",
8686
"rollup-plugin-buble": "^0.19.8",
8787
"rollup-plugin-commonjs": "^10.1.0",
8888
"rollup-plugin-node-resolve": "^5.2.0",
8989
"rollup-plugin-replace": "^2.2.0",
90-
"rollup-plugin-terser": "^5.1.1",
91-
"styled-components": "^4.3.2"
90+
"rollup-plugin-terser": "^5.2.0"
9291
}
9392
}

src/__tests__/visitor.test.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import React, {
1111
} from 'react'
1212

1313
import { createPortal } from 'react-dom'
14-
import styled from 'styled-components'
1514

1615
import {
1716
Dispatcher,
@@ -30,10 +29,6 @@ const {
3029
ReactCurrentDispatcher
3130
} = (React: any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
3231

33-
const {
34-
StyleSheet
35-
} = require('styled-components').__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS
36-
3732
let prevDispatcher = null
3833

3934
beforeEach(() => {
@@ -51,10 +46,6 @@ afterEach(() => {
5146
const Noop = () => null
5247

5348
describe('visitElement', () => {
54-
beforeEach(() => {
55-
StyleSheet.reset(true)
56-
})
57-
5849
it('walks Fragments', () => {
5950
const element = (
6051
<Fragment>
@@ -107,43 +98,6 @@ describe('visitElement', () => {
10798
expect(children[1].type).toBe(Noop)
10899
})
109100

110-
it('walks StyledComponent DOM elements', () => {
111-
const Comp = styled.div``
112-
const children = visitElement(
113-
<Comp>
114-
<Noop />
115-
</Comp>,
116-
[],
117-
() => {}
118-
)
119-
120-
expect(children.length).toBe(1)
121-
expect(children[0].type).toBe(Noop)
122-
expect(StyleSheet.master.tags.length).toBe(1)
123-
124-
const tag = StyleSheet.master.tags[0]
125-
expect(tag.css().trim()).toBe('')
126-
127-
expect(Object.keys(StyleSheet.master.deferred)).toEqual([
128-
expect.any(String)
129-
])
130-
})
131-
132-
it('walks StyledComponent wrapper elements', () => {
133-
const Comp = styled(Noop)``
134-
const children = visitElement(<Comp />, [], () => {})
135-
136-
expect(children.length).toBe(1)
137-
expect(StyleSheet.master.tags.length).toBe(1)
138-
139-
const tag = StyleSheet.master.tags[0]
140-
expect(tag.css().trim()).toBe('')
141-
142-
expect(Object.keys(StyleSheet.master.deferred)).toEqual([
143-
expect.any(String)
144-
])
145-
})
146-
147101
it('walks Providers and Consumers', () => {
148102
const Context = createContext('default')
149103
const leaf = jest.fn().mockReturnValue(null)

src/render/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,3 @@ export {
2222
mount as mountClassComponent,
2323
update as updateClassComponent
2424
} from './classComponent'
25-
26-
export {
27-
isStyledElement,
28-
mount as mountStyledComponent
29-
} from './styledComponent'

src/render/styledComponent.js

Lines changed: 0 additions & 110 deletions
This file was deleted.

src/visitor.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ import {
1515
mountClassComponent,
1616
updateClassComponent,
1717
mountLazyComponent,
18-
updateLazyComponent,
19-
mountStyledComponent,
20-
isStyledElement
18+
updateLazyComponent
2119
} from './render'
2220

2321
import type {
@@ -143,13 +141,6 @@ export const visitElement = (
143141

144142
case REACT_FORWARD_REF_TYPE: {
145143
const refElement = ((element: any): ForwardRefElement)
146-
147-
// If we find a StyledComponent, we trigger a specific optimisation
148-
// that allows quick rendering of them without computing styles
149-
if (isStyledElement(refElement)) {
150-
return mountStyledComponent(refElement)
151-
}
152-
153144
const { render: type, defaultProps } = refElement.type
154145
const props = computeProps(refElement.props, defaultProps)
155146
const child = createElement((type: any), props)

0 commit comments

Comments
 (0)