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

Fixed benchmarks app #3297

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let isTestFile = filename =>
module.exports = api => {
api.cache(true)
return {
presets: ['babel-preset-emotion-dev', '@babel/preset-typescript'],
presets: [emotionDevPreset, '@babel/preset-typescript'],
overrides: [
{
test: filename =>
Expand Down Expand Up @@ -49,6 +49,15 @@ module.exports = api => {
{ runtime: 'automatic', development: true, useEmotionPlugin: true }
]
]
},
{
test: filename => filename && filename.includes('scripts/benchmarks'),
presets: [
[
emotionDevPreset,
{ runtime: 'automatic', development: false, useEmotionPlugin: true }
]
]
}
]
}
Expand Down
6 changes: 3 additions & 3 deletions docs/ssr.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -265,16 +265,16 @@ index.js
```jsx
// This has to be run before emotion inserts any styles so it's imported before the App component
import './disable-speedy'
import ReactDOM from 'react-dom'
import { createRoot, hydrateRoot } from 'react-dom/client'
import App from './App'

const root = document.getElementById('root')

// Check if the root node has any children to detect if the app has been prerendered
if (root.hasChildNodes()) {
ReactDOM.hydrate(<App />, root)
hydrateRoot(root, <App />)
} else {
ReactDOM.render(<App />, root)
createRoot(root).render(<App />)
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'react-app-polyfill/ie11'
import 'react-app-polyfill/stable'

import React from 'react'
import ReactDOM from 'react-dom'
import { createRoot } from 'react-dom/client'
import App from './App'

ReactDOM.render(<App />, document.getElementById('root'))
createRoot(document.getElementById('root')).render(<App />)
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import 'react-app-polyfill/ie11'
import 'react-app-polyfill/stable'

import React from 'react'
import ReactDOM from 'react-dom'
import { createRoot } from 'react-dom/client'
import App from './App'

ReactDOM.render(<App />, document.getElementById('root'))
createRoot(document.getElementById('root')).render(<App />)


↓ ↓ ↓ ↓ ↓ ↓
Expand All @@ -18,10 +18,10 @@ ReactDOM.render(<App />, document.getElementById('root'))
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import App from './App';
import { jsx as ___EmotionJSX } from "@emotion/react";
ReactDOM.render(<App />, document.getElementById('root'));"
createRoot(document.getElementById('root')).render(<App />);"
`;

exports[`@emotion/babel-plugin-jsx-pragmatic fragment-only 1`] = `
Expand Down
7 changes: 3 additions & 4 deletions playgrounds/cra/src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { createRoot, hydrateRoot } from 'react-dom/client'
import App from './App'

ReactDOM.render(
createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
</React.StrictMode>
)
12 changes: 0 additions & 12 deletions scripts/benchmarks/.babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions scripts/benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@
},
"alias": {
"react-native": "react-native-web"
},
"@parcel/resolver-default": {
"packageExports": true
}
}
4 changes: 0 additions & 4 deletions scripts/benchmarks/src/app/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import { colors } from './theme'
class AppText extends React.Component {
static displayName = '@app/Text'

static contextTypes = {
isInAParentText: bool
}

render() {
const { style, ...rest } = this.props
const { isInAParentText } = this.context
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jsx jsx */
/** @jsxImportSource @emotion/react */
import { viewStyle } from './View'
import { css, jsx } from '@emotion/react'
import { css } from '@emotion/react'

const Box = ({
color,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @jsx jsx */
import { css, jsx } from '@emotion/react'
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react'

const Dot = ({ size, x, y, children, color }) => (
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @jsx jsx */
import { css, jsx } from '@emotion/react'
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react'

const View = ({ style, ...other }) => {
return <div {...other} css={css(viewStyle, style)} />
Expand Down
4 changes: 2 additions & 2 deletions scripts/benchmarks/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Tree from './cases/Tree'
import SierpinskiTriangle from './cases/SierpinskiTriangle'

import React from 'react'
import ReactDOM from 'react-dom'
import { createRoot } from 'react-dom/client'

const packageNames = Object.keys(implementations)

Expand Down Expand Up @@ -76,4 +76,4 @@ if (!root) {
throw new Error('could not find root')
}

ReactDOM.render(<App tests={tests} />, root)
createRoot(root).render(<App tests={tests} />)
Loading