From 85ae7ea37fecb84a7a1ebb7a5f70b2921bc1100b Mon Sep 17 00:00:00 2001 From: Willy Brauner Date: Wed, 18 Oct 2023 17:32:49 +0200 Subject: [PATCH] Update example --- examples/example-ssr/src/pages/ContactPage.tsx | 6 ++---- examples/example-ssr/vite.scripts.config.ts | 2 ++ package.json | 2 +- src/components/Router.tsx | 5 ++--- tsup.config.ts | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/example-ssr/src/pages/ContactPage.tsx b/examples/example-ssr/src/pages/ContactPage.tsx index 0be31353..66a477c6 100644 --- a/examples/example-ssr/src/pages/ContactPage.tsx +++ b/examples/example-ssr/src/pages/ContactPage.tsx @@ -1,12 +1,11 @@ import React, {useState, useRef} from "react" import { useStack } from "@cher-ami/router"; -import {transitionsHelper} from "../helpers/transitionsHelper" +import {transitionsHelper} from "~/helpers/transitionsHelper" const componentName = "ContactPage" function ContactPage(props, handleRef) { const rootRef = useRef(null) - const [n, setN] = useState(0) - + useStack({ componentName, handleRef, @@ -15,7 +14,6 @@ function ContactPage(props, handleRef) { playOut: () => transitionsHelper(rootRef.current, false, { x: -0 }, { x: 50 }), }); - return (
{componentName} diff --git a/examples/example-ssr/vite.scripts.config.ts b/examples/example-ssr/vite.scripts.config.ts index 3f62bb4d..fd0aad2f 100644 --- a/examples/example-ssr/vite.scripts.config.ts +++ b/examples/example-ssr/vite.scripts.config.ts @@ -27,6 +27,8 @@ export default defineConfig(({ command, mode }) => { chunkFileNames: `[name].js`, assetFileNames: `[name].[ext]`, }, + + external: ["react", "react-dom"], }, }, diff --git a/package.json b/package.json index 3648c8f2..8c34ce2c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "build:example-ssr": "pnpm --filter ./examples/example-ssr run build", "size": "size-limit", "size-why": "size-limit -- --why", - "test": "jest", + "test": "jest && npm run size", "test:watch": "jest --watch", "pre-publish": "npm run build && npm run test" }, diff --git a/src/components/Router.tsx b/src/components/Router.tsx index 33c030cf..7efc824d 100644 --- a/src/components/Router.tsx +++ b/src/components/Router.tsx @@ -313,7 +313,7 @@ function Router(props: { // prettier-ignore if (isServer) { if (props.initialStaticProps) { - log("firstRoute > isServer > assign initialStaticProps to newRoute props & set cache",); + log("firstRoute > isServer > assign initialStaticProps to newRoute props & set cache"); Object.assign(newRoute.props, props.initialStaticProps?.props ?? {}); } } @@ -323,8 +323,7 @@ function Router(props: { // CLIENT > FIRST ROUTE if (Routers.isFirstRoute) { if (props.initialStaticProps) { - // assign initial static props to new route props & set cache - log(props.id, "firstRoute > isClient > assign initial static props to new route props & set cache"); + log(props.id, "firstRoute > isClient > assign initialStaticProps to newRoute props & set cache"); Object.assign(newRoute.props, props.initialStaticProps?.props ?? {}); cache.set(urlWithoutHash, newRoute.props ?? {}); } diff --git a/tsup.config.ts b/tsup.config.ts index 54f66ecb..fb57f3e3 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ dts: true, format: ["cjs", "esm"], name: "@cher-ami/router", - external: ["@wbe/debug", "history", "path-to-regexp", "react"], + external: ["@wbe/debug", "history", "path-to-regexp", "react", "react-dom"], sourcemap: true, async onSuccess() { const process = spawn("npx", ["size-limit"], { shell: true });