From 0e0312ca2bf3f373e978d04b13ead065684f9557 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Wed, 7 Sep 2022 08:48:44 +0200 Subject: [PATCH 1/3] Update dependencies --- examples/using-preact/package.json | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/using-preact/package.json b/examples/using-preact/package.json index 0f8d828fc183..fc8272845950 100644 --- a/examples/using-preact/package.json +++ b/examples/using-preact/package.json @@ -5,14 +5,13 @@ "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" } } From 79b034a234683e4f1abb98a02b7214e1ce278fd5 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Wed, 7 Sep 2022 09:26:02 +0200 Subject: [PATCH 2/3] [Docs] Migrate using-preact example to typescript --- examples/using-preact/next.config.js | 7 ++++-- examples/using-preact/package.json | 4 ++++ examples/using-preact/pages/about.js | 3 --- examples/using-preact/pages/about.tsx | 3 +++ .../pages/{index.js => index.tsx} | 2 +- examples/using-preact/pages/ssg.js | 9 -------- examples/using-preact/pages/ssg.tsx | 13 +++++++++++ examples/using-preact/pages/ssr.js | 9 -------- examples/using-preact/pages/ssr.tsx | 13 +++++++++++ examples/using-preact/tsconfig.json | 22 +++++++++++++++++++ 10 files changed, 61 insertions(+), 24 deletions(-) delete mode 100644 examples/using-preact/pages/about.js create mode 100644 examples/using-preact/pages/about.tsx rename examples/using-preact/pages/{index.js => index.tsx} (91%) delete mode 100644 examples/using-preact/pages/ssg.js create mode 100644 examples/using-preact/pages/ssg.tsx delete mode 100644 examples/using-preact/pages/ssr.js create mode 100644 examples/using-preact/pages/ssr.tsx create mode 100644 examples/using-preact/tsconfig.json diff --git a/examples/using-preact/next.config.js b/examples/using-preact/next.config.js index cffe26659035..f0e665c2218a 100644 --- a/examples/using-preact/next.config.js +++ b/examples/using-preact/next.config.js @@ -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) diff --git a/examples/using-preact/package.json b/examples/using-preact/package.json index fc8272845950..c14ee3810cd7 100644 --- a/examples/using-preact/package.json +++ b/examples/using-preact/package.json @@ -13,5 +13,9 @@ "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", + "typescript": "4.8.2" } } diff --git a/examples/using-preact/pages/about.js b/examples/using-preact/pages/about.js deleted file mode 100644 index 46817af02a5c..000000000000 --- a/examples/using-preact/pages/about.js +++ /dev/null @@ -1,3 +0,0 @@ -export default function About() { - return
About us
-} diff --git a/examples/using-preact/pages/about.tsx b/examples/using-preact/pages/about.tsx new file mode 100644 index 000000000000..71c7703a7bd2 --- /dev/null +++ b/examples/using-preact/pages/about.tsx @@ -0,0 +1,3 @@ +export default function AboutPage() { + return
About us
+} diff --git a/examples/using-preact/pages/index.js b/examples/using-preact/pages/index.tsx similarity index 91% rename from examples/using-preact/pages/index.js rename to examples/using-preact/pages/index.tsx index 62301b996922..a0051fe32b9f 100644 --- a/examples/using-preact/pages/index.js +++ b/examples/using-preact/pages/index.tsx @@ -1,6 +1,6 @@ import Link from 'next/link' -export default function Home() { +export default function IndexPage() { return (
Hello World.{' '} diff --git a/examples/using-preact/pages/ssg.js b/examples/using-preact/pages/ssg.js deleted file mode 100644 index 58adabc4b5b7..000000000000 --- a/examples/using-preact/pages/ssg.js +++ /dev/null @@ -1,9 +0,0 @@ -export default function SSG({ framework }) { - return
{framework} ssg example
-} - -export function getStaticProps() { - return { - props: { framework: 'preact' }, - } -} diff --git a/examples/using-preact/pages/ssg.tsx b/examples/using-preact/pages/ssg.tsx new file mode 100644 index 000000000000..ef13cface3bb --- /dev/null +++ b/examples/using-preact/pages/ssg.tsx @@ -0,0 +1,13 @@ +import { InferGetStaticPropsType } from 'next' + +export function getStaticProps() { + return { + props: { framework: 'preact' }, + } +} + +export default function SSGPage({ + framework, +}: InferGetStaticPropsType) { + return
{framework} ssg example
+} diff --git a/examples/using-preact/pages/ssr.js b/examples/using-preact/pages/ssr.js deleted file mode 100644 index 695e329a8591..000000000000 --- a/examples/using-preact/pages/ssr.js +++ /dev/null @@ -1,9 +0,0 @@ -export default function SSR({ framework }) { - return
{framework} ssr example
-} - -export function getServerSideProps() { - return { - props: { framework: 'preact' }, - } -} diff --git a/examples/using-preact/pages/ssr.tsx b/examples/using-preact/pages/ssr.tsx new file mode 100644 index 000000000000..24c86325aa72 --- /dev/null +++ b/examples/using-preact/pages/ssr.tsx @@ -0,0 +1,13 @@ +import { InferGetServerSidePropsType } from 'next' + +export function getServerSideProps() { + return { + props: { framework: 'preact' }, + } +} + +export default function SSRPage({ + framework, +}: InferGetServerSidePropsType) { + return
{framework} ssr example
+} diff --git a/examples/using-preact/tsconfig.json b/examples/using-preact/tsconfig.json new file mode 100644 index 000000000000..f83cb8071c2e --- /dev/null +++ b/examples/using-preact/tsconfig.json @@ -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"] +} From d4695b9be5ed5ef846cec94cb8d5019fe5c13d64 Mon Sep 17 00:00:00 2001 From: Henrik Wenz Date: Wed, 7 Sep 2022 11:38:01 +0200 Subject: [PATCH 3/3] Add @types/react --- examples/using-preact/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/using-preact/package.json b/examples/using-preact/package.json index c14ee3810cd7..dc2b8b3f46da 100644 --- a/examples/using-preact/package.json +++ b/examples/using-preact/package.json @@ -16,6 +16,7 @@ }, "devDependencies": { "@types/node": "18.7.15", + "@types/react": "16.9.17", "typescript": "4.8.2" } }