-
Notifications
You must be signed in to change notification settings - Fork 0
Ssr-safe #2
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
Merged
Ssr-safe #2
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fe00886
polish
Eliav2 caf1ef1
Update dependencies, enhance demo configurations, and add SSR support
Eliav2 2f79ecf
ssr-setup
Eliav2 b0fb38c
ssr
Eliav2 a8d7699
amount
Eliav2 43da54b
changelog
Eliav2 9d55da7
0.2.0
Eliav2 a9df327
polish
Eliav2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
|
|
||
| import App from '../../src/App.tsx' | ||
| export { Page } | ||
|
|
||
| function Page() { | ||
| return <> | ||
| <App /> | ||
| </> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type { Config } from "vike/types"; | ||
| import vikeReact from "vike-react/config"; | ||
|
|
||
| const isSpa = (process.env.VITE_APP_MODE ?? "ssr") === "spa"; | ||
|
|
||
| export default { | ||
| prerender: true, | ||
| extends: [vikeReact], | ||
| ssr: !isSpa, | ||
| } satisfies Config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { OverflowList } from "react-responsive-overflow-list"; | ||
| import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; | ||
| import { tomorrow } from "react-syntax-highlighter/dist/esm/styles/prism"; | ||
|
|
||
| const tags = ["React", "TypeScript", "CSS", "JavaScript", "HTML", "Node.js", "Express", "MongoDB", "PostgreSQL", "Redis"]; | ||
|
|
||
| export function ReverseOrderExample() { | ||
| return ( | ||
| <section className="demo"> | ||
| <h2 id="reverse-order-example">Reverse Order Example</h2> | ||
| <p>Compare normal overflow (shrinks from end) vs reverse overflow (shrinks from start)</p> | ||
| <div className="code-preview"> | ||
| <SyntaxHighlighter language="tsx" style={tomorrow}> | ||
| {`// Normal overflow - shrinks from end | ||
| <OverflowList | ||
| items={tags} | ||
| renderItem={(item, index) => ( | ||
| <span key={index} className="tag-item"> | ||
| {item} | ||
| </span> | ||
| )} | ||
| style={{ gap: "8px" }} | ||
| /> | ||
|
|
||
| // Reverse overflow - shrinks from start | ||
| <OverflowList | ||
| items={[...tags].reverse()} | ||
| renderItem={(item, index) => ( | ||
| <span key={index} className="tag-item"> | ||
| {item} | ||
| </span> | ||
| )} | ||
| style={{ | ||
| gap: "8px", | ||
| flexDirection: "row-reverse", | ||
| justifyContent: "flex-end" | ||
| }} | ||
| />`} | ||
| </SyntaxHighlighter> | ||
| </div> | ||
|
|
||
| <div className="demo-section"> | ||
| <h3>Normal Overflow (shrinks from end)</h3> | ||
| <div className="demo-container"> | ||
| <OverflowList | ||
| items={tags} | ||
| renderItem={(item, index) => ( | ||
| <span key={index} className="tag-item"> | ||
| {item} | ||
| </span> | ||
| )} | ||
| style={{ gap: "8px" }} | ||
| /> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="demo-section"> | ||
| <h3>Reverse Overflow (shrinks from start)</h3> | ||
| <div className="demo-container"> | ||
| <OverflowList | ||
| items={[...tags].reverse()} | ||
| renderItem={(item, index) => ( | ||
| <span key={index} className="tag-item"> | ||
| {item} | ||
| </span> | ||
| )} | ||
| style={{ | ||
| gap: "8px", | ||
| flexDirection: "row-reverse", | ||
| justifyContent: "flex-end" | ||
| }} | ||
| /> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,26 @@ | ||
| import { defineConfig } from "vite"; | ||
| import react from "@vitejs/plugin-react"; | ||
| import { fileURLToPath, URL } from "node:url"; | ||
| import { vitePrerenderPlugin } from "vite-prerender-plugin"; | ||
| import path from "node:path"; | ||
| import vike from "vike/plugin"; | ||
|
|
||
| export default defineConfig({ | ||
| plugins: [ | ||
| react(), | ||
| vitePrerenderPlugin({ | ||
| renderTarget: "#root", | ||
| prerenderScript: path.resolve(__dirname, "src/prerender.tsx"), | ||
| }), | ||
| ], | ||
| base: process.env.NODE_ENV === "production" ? "/react-responsive-overflow-list/" : "/", | ||
| resolve: { | ||
| // trick to avoid needing to build-watch the library when developing the demo | ||
| alias: { | ||
| "react-responsive-overflow-list": fileURLToPath(new URL("../src/index.ts", import.meta.url)), | ||
| export default defineConfig(() => { | ||
| const appMode = process.env.VITE_APP_MODE || ("spa" as "spa" | "ssr"); | ||
| console.log(`VITE_APP_MODE is "${appMode}"`); | ||
|
|
||
| return { | ||
| plugins: [react(), vike()], | ||
| ssr: { | ||
| // Don't externalize React for SSR | ||
| noExternal: ["react-responsive-overflow-list", "react-syntax-highlighter", "@types/react-syntax-highlighter"], | ||
| // Handle CommonJS modules | ||
| // external: ["react-copy-to-clipboard"], | ||
| }, | ||
| base: process.env.NODE_ENV === "production" ? "/react-responsive-overflow-list/" : "/", | ||
| resolve: { | ||
| // trick to avoid needing to build-watch the library when developing the demo | ||
| alias: { | ||
| "react-responsive-overflow-list": fileURLToPath(new URL("../src/index.ts", import.meta.url)), | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Dynamic Import State Error
The
CopyToClipboardWrappercomponent's dynamic import has two issues: it sets state to a function that returnsmodule.defaultinstead of the component itself, and it usesmodule.defaultwhenCopyToClipboardwas a named export. This causes a runtime error when React tries to render a function as a component.