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: stop overriding Wrapper meta #160

Merged
merged 7 commits into from
Dec 28, 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
2 changes: 1 addition & 1 deletion examples/apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.3.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vike-react-apollo": "^0.1.1",
"@apollo/client": "^3.10.8",
Expand Down
2 changes: 1 addition & 1 deletion examples/full/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react-dom": "^18.3.1",
"react-streaming": "^0.3.43",
"typescript": "^5.5.4",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vite": "^5.4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.5.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vike-react-query": "^0.1.3",
"@tanstack/react-query": "^5.20.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import { usePageContext } from 'vike-react/usePageContext'
function Wrapper({ children }: { children: ReactNode }) {
const pageContext = usePageContext()
const { antd } = pageContext.config
const cache = 'antd' in pageContext ? pageContext.antd?.cache : undefined

if (antd === null || !cache) {
if (antd === null) {
return <>{children}</>
}

return (
<StyleProvider cache={cache} {...antd}>
<StyleProvider cache={pageContext.antd!.cache} {...antd}>
{children}
</StyleProvider>
)
Expand Down
5 changes: 1 addition & 4 deletions packages/vike-react-antd/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import type { Config } from 'vike/types'
const config = {
name: 'vike-react-antd',
require: {
vike: '>=0.4.203',
vike: '>=0.4.211',
'vike-react': '>=0.4.13',
},
onAfterRenderHtml: 'import:vike-react-antd/__internal/onAfterRenderHtml:onAfterRenderHtml',
onBeforeRenderHtml: 'import:vike-react-antd/__internal/onBeforeRenderHtml:onBeforeRenderHtml',
Wrapper: 'import:vike-react-antd/__internal/Wrapper:Wrapper',
meta: {
Wrapper: {
env: { server: true },
},
antd: {
env: {
server: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/vike-react-antd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"./config": "./dist/config.js",
"./__internal/onAfterRenderHtml": "./dist/onAfterRenderHtml.js",
"./__internal/onBeforeRenderHtml": "./dist/onBeforeRenderHtml.js",
"./__internal/Wrapper": "./dist/Wrapper.js"
"./__internal/Wrapper": "./dist/Wrapper.server.js"
},
"scripts": {
"dev": "tsc --watch",
Expand All @@ -30,7 +30,7 @@
"react": "^18.3.1",
"rimraf": "^5.0.5",
"typescript": "^5.5.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vite": "^5.4.0"
},
Expand All @@ -46,7 +46,7 @@
"dist/onBeforeRenderHtml.d.ts"
],
"__internal/Wrapper": [
"dist/Wrapper.d.ts"
"dist/Wrapper.server.d.ts"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vike-react-apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react-streaming": "^0.3.43",
"rimraf": "^5.0.5",
"typescript": "^5.3.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vite": "^5.4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vike-react-chakra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"react": "^18.3.1",
"rimraf": "^5.0.5",
"typescript": "^5.5.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vite": "^5.4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vike-react-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"react-streaming": "^0.3.43",
"rimraf": "^5.0.5",
"typescript": "^5.5.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vite": "^5.4.0",
"vitest": "^1.2.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import { usePageContext } from 'vike-react/usePageContext'
function Wrapper({ children }: { children: ReactNode }) {
const pageContext = usePageContext()
const { styledComponents } = pageContext.config
const sheet = 'styledComponents' in pageContext ? pageContext.styledComponents?.sheet : undefined

if (styledComponents === null || !sheet) {
if (styledComponents === null) {
return <>{children}</>
}

return (
<StyleSheetManager sheet={sheet.instance} {...styledComponents?.styleSheetManager}>
<StyleSheetManager sheet={pageContext.styledComponents!.sheet?.instance} {...styledComponents?.styleSheetManager}>
{children}
</StyleSheetManager>
)
Expand Down
5 changes: 1 addition & 4 deletions packages/vike-react-styled-components/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import type { Config } from 'vike/types'
const config = {
name: 'vike-react-styled-components',
require: {
vike: '>=0.4.203',
vike: '>=0.4.211',
'vike-react': '>=0.4.13',
},
onAfterRenderHtml: 'import:vike-react-styled-components/__internal/onAfterRenderHtml:onAfterRenderHtml',
onBeforeRenderHtml: 'import:vike-react-styled-components/__internal/onBeforeRenderHtml:onBeforeRenderHtml',
Wrapper: 'import:vike-react-styled-components/__internal/Wrapper:Wrapper',
meta: {
Wrapper: {
env: { server: true },
},
styledComponents: {
env: {
server: true,
Expand Down
6 changes: 3 additions & 3 deletions packages/vike-react-styled-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"./config": "./dist/config.js",
"./__internal/onAfterRenderHtml": "./dist/onAfterRenderHtml.js",
"./__internal/onBeforeRenderHtml": "./dist/onBeforeRenderHtml.js",
"./__internal/Wrapper": "./dist/Wrapper.js"
"./__internal/Wrapper": "./dist/Wrapper.server.js"
},
"scripts": {
"dev": "tsc --watch",
Expand All @@ -28,7 +28,7 @@
"rimraf": "^5.0.5",
"styled-components": "^6.1.13",
"typescript": "^5.5.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vite": "^5.4.0"
},
Expand All @@ -44,7 +44,7 @@
"dist/onBeforeRenderHtml.d.ts"
],
"__internal/Wrapper": [
"dist/Wrapper.d.ts"
"dist/Wrapper.server.d.ts"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import { usePageContext } from 'vike-react/usePageContext'
function Wrapper({ children }: { children: ReactNode }) {
const pageContext = usePageContext()
const { styledJsx } = pageContext.config
const registry = 'styledJsx' in pageContext ? pageContext.styledJsx?.registry : undefined

if (styledJsx === null || !registry) {
if (styledJsx === null) {
return <>{children}</>
}

return <StyleRegistry registry={registry}>{children}</StyleRegistry>
return <StyleRegistry registry={pageContext.styledJsx!.registry}>{children}</StyleRegistry>
}
5 changes: 1 addition & 4 deletions packages/vike-react-styled-jsx/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { StyledJsxStyleRegistry } from 'styled-jsx'
const config = {
name: 'vike-react-styled-jsx',
require: {
vike: '>=0.4.203',
vike: '>=0.4.211',
'vike-react': '>=0.4.13',
},
onBeforeRenderHtml: 'import:vike-react-styled-jsx/__internal/onBeforeRenderHtml:onBeforeRenderHtml',
Expand All @@ -16,9 +16,6 @@ const config = {
styledJsx: {
env: { server: true },
},
Wrapper: {
env: { server: true },
},
},
} satisfies Config

Expand Down
6 changes: 3 additions & 3 deletions packages/vike-react-styled-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"./config": "./dist/config.js",
"./__internal/onAfterRenderHtml": "./dist/onAfterRenderHtml.js",
"./__internal/onBeforeRenderHtml": "./dist/onBeforeRenderHtml.js",
"./__internal/Wrapper": "./dist/Wrapper.js"
"./__internal/Wrapper": "./dist/Wrapper.server.js"
},
"scripts": {
"dev": "tsc --watch",
Expand All @@ -28,7 +28,7 @@
"rimraf": "^5.0.5",
"styled-jsx": "^5.1.6",
"typescript": "^5.5.3",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vike-react": "^0.5.11",
"vite": "^5.4.0"
},
Expand All @@ -44,7 +44,7 @@
"dist/onBeforeRenderHtml.d.ts"
],
"__internal/Wrapper": [
"dist/Wrapper.d.ts"
"dist/Wrapper.server.d.ts"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vike-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"react-streaming": "^0.3.43",
"rimraf": "^5.0.5",
"typescript": "^5.5.4",
"vike": "^0.4.203",
"vike": "^0.4.211",
"vite": "^5.4.0"
},
"typesVersions": {
Expand Down
Loading
Loading