Skip to content

Commit

Permalink
Merge branch 'canary' into feat/configurable-dynamic-guards
Browse files Browse the repository at this point in the history
  • Loading branch information
feugy committed Sep 8, 2022
2 parents 67379c0 + a4d907a commit 0c53200
Show file tree
Hide file tree
Showing 57 changed files with 582 additions and 138 deletions.
1 change: 0 additions & 1 deletion .github/workflows/validate_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ jobs:
run: node ./.github/actions/issue-validator/index.mjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEBUG: 1
2 changes: 1 addition & 1 deletion examples/react-remove-properties/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
module.exports = {
experimental: {
compiler: {
reactRemoveProperties: true,
// Or, specify a custom list of regular expressions to match properties to remove.
// The regexes defined here are processed in Rust so the syntax is different from
Expand Down
7 changes: 5 additions & 2 deletions examples/using-preact/next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const withPreact = require('next-plugin-preact')

module.exports = withPreact({
/** @type {import('next').NextConfig} */
const nextConfig = {
/* regular next.js config options here */
})
}

module.exports = withPreact(nextConfig)
20 changes: 12 additions & 8 deletions examples/using-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
"build": "next build",
"start": "next start"
},
"devDependencies": {},
"dependencies": {
"next": "^12.0.0",
"next-plugin-preact": "^3.0.6",
"preact": "^10.5.15",
"preact-render-to-string": "^5.1.19",
"react": "npm:@preact/compat@^17.0.2",
"react-dom": "npm:@preact/compat@^17.0.2",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.2.0"
"next": "latest",
"next-plugin-preact": "latest",
"preact": "^10.10.6",
"preact-render-to-string": "^5.2.3",
"react": "npm:@preact/compat@^17.1.1",
"react-dom": "npm:@preact/compat@^17.1.1",
"react-ssr-prepass": "npm:preact-ssr-prepass@1.2.0"
},
"devDependencies": {
"@types/node": "18.7.15",
"@types/react": "16.9.17",
"typescript": "4.8.2"
}
}
3 changes: 0 additions & 3 deletions examples/using-preact/pages/about.js

This file was deleted.

3 changes: 3 additions & 0 deletions examples/using-preact/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function AboutPage() {
return <div>About us</div>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from 'next/link'

export default function Home() {
export default function IndexPage() {
return (
<div>
Hello World.{' '}
Expand Down
9 changes: 0 additions & 9 deletions examples/using-preact/pages/ssg.js

This file was deleted.

13 changes: 13 additions & 0 deletions examples/using-preact/pages/ssg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { InferGetStaticPropsType } from 'next'

export function getStaticProps() {
return {
props: { framework: 'preact' },
}
}

export default function SSGPage({
framework,
}: InferGetStaticPropsType<typeof getStaticProps>) {
return <div>{framework} ssg example</div>
}
9 changes: 0 additions & 9 deletions examples/using-preact/pages/ssr.js

This file was deleted.

13 changes: 13 additions & 0 deletions examples/using-preact/pages/ssr.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { InferGetServerSidePropsType } from 'next'

export function getServerSideProps() {
return {
props: { framework: 'preact' },
}
}

export default function SSRPage({
framework,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
return <div>{framework} ssr example</div>
}
22 changes: 22 additions & 0 deletions examples/using-preact/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"moduleResolution": "node",
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
31 changes: 0 additions & 31 deletions examples/with-context-api/components/Counter.js

This file was deleted.

57 changes: 57 additions & 0 deletions examples/with-context-api/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {
useReducer,
useContext,
createContext,
ReactNode,
Dispatch,
} from 'react'

type CounterState = number
type CounterAction =
| {
type: 'INCREASE' | 'DECREASE'
}
| {
type: 'INCREASE_BY'
payload: number
}

const CounterStateContext = createContext<CounterState>(0)
const CounterDispatchContext = createContext<Dispatch<CounterAction>>(
() => null
)

const reducer = (state: CounterState, action: CounterAction) => {
switch (action.type) {
case 'INCREASE':
return state + 1
case 'DECREASE':
return state - 1
case 'INCREASE_BY':
return state + action.payload
default:
throw new Error(`Unknown action: ${JSON.stringify(action)}`)
}
}

type CounterProviderProps = {
children: ReactNode
initialValue?: number
}

export const CounterProvider = ({
children,
initialValue = 0,
}: CounterProviderProps) => {
const [state, dispatch] = useReducer(reducer, initialValue)
return (
<CounterDispatchContext.Provider value={dispatch}>
<CounterStateContext.Provider value={state}>
{children}
</CounterStateContext.Provider>
</CounterDispatchContext.Provider>
)
}

export const useCount = () => useContext(CounterStateContext)
export const useDispatchCount = () => useContext(CounterDispatchContext)
9 changes: 7 additions & 2 deletions examples/with-context-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
},
"dependencies": {
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "18.7.15",
"@types/react": "16.9.17",
"typescript": "4.8.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { AppProps } from 'next/app'
import { CounterProvider } from '../components/Counter'

function MyApp({ Component, pageProps }) {
export default function MyApp({ Component, pageProps }: AppProps) {
return (
<CounterProvider>
<Component {...pageProps} />
</CounterProvider>
)
}

export default MyApp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { MouseEvent } from 'react'
import Link from 'next/link'
import { useCount, useDispatchCount } from '../components/Counter'

const AboutPage = () => {
const count = useCount()
const dispatch = useDispatchCount()

const handleIncrease = (event) =>
const handleIncrease = (event: MouseEvent<HTMLButtonElement>) =>
dispatch({
type: 'INCREASE',
})
const handleIncrease15 = (event) =>
const handleIncrease15 = (event: MouseEvent<HTMLButtonElement>) =>
dispatch({
type: 'INCREASE_BY',
payload: 15,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { MouseEvent } from 'react'
import Link from 'next/link'
import { useCount, useDispatchCount } from '../components/Counter'

const IndexPage = () => {
const count = useCount()
const dispatch = useDispatchCount()

const handleIncrease = (event) =>
const handleIncrease = (event: MouseEvent<HTMLButtonElement>) =>
dispatch({
type: 'INCREASE',
})
const handleDecrease = (event) =>
const handleDecrease = (event: MouseEvent<HTMLButtonElement>) =>
dispatch({
type: 'DECREASE',
})
Expand Down
20 changes: 20 additions & 0 deletions examples/with-context-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"moduleResolution": "node",
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
3 changes: 0 additions & 3 deletions examples/with-react-jss/.babelrc

This file was deleted.

11 changes: 8 additions & 3 deletions examples/with-react-jss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
},
"dependencies": {
"next": "latest",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-jss": "^10.3.0"
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-jss": "^10.9.2"
},
"devDependencies": {
"@types/node": "18.7.15",
"@types/react": "18.0.18",
"typescript": "4.8.2"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { AppProps } from 'next/app'
import { useEffect } from 'react'

export default function App({ Component, pageProps }) {
export default function App({ Component, pageProps }: AppProps) {
useEffect(() => {
const style = document.getElementById('server-side-styles')
if (style) {
if (style && style.parentNode) {
style.parentNode.removeChild(style)
}
}, [])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Document from 'next/document'
import Document, { DocumentContext } from 'next/document'
import { SheetsRegistry, JssProvider, createGenerateId } from 'react-jss'

export default class JssDocument extends Document {
static async getInitialProps(ctx) {
static async getInitialProps(ctx: DocumentContext) {
const registry = new SheetsRegistry()
const generateId = createGenerateId()
const originalRenderPage = ctx.renderPage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const useStyles = createUseStyles({
},
})

function Index() {
export default function IndexPage() {
const classes = useStyles()

return (
Expand All @@ -23,5 +23,3 @@ function Index() {
</div>
)
}

export default Index
20 changes: 20 additions & 0 deletions examples/with-react-jss/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"incremental": true,
"esModuleInterop": true,
"moduleResolution": "node",
"module": "esnext",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}

0 comments on commit 0c53200

Please sign in to comment.