-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: vite deps optimizer usage (#26)
With this PR the framework in development mode relies on Vite's dependency optimizer in a cleaner and simpler way to handle CommonJS dependencies. Adds a new Chakra UI example to have another third-party library usage as a test case for module resolution. Cleans up some inline Vite / Rollup plugin code. Another possible enhancement to fix issues around third-party libraries, related to issues: - Mantine / use client not respected #20 - MUI 6.x / React__namespace.createContext is not a function #22
- Loading branch information
Showing
15 changed files
with
1,577 additions
and
167 deletions.
There are no files selected for viewing
This file contains 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,4 @@ | ||
"use client"; | ||
|
||
import { Button, Spinner } from "@chakra-ui/react"; | ||
export { Button, Spinner }; |
This file contains 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,7 @@ | ||
"use client"; | ||
|
||
import { ChakraProvider } from "@chakra-ui/react"; | ||
|
||
export default function Providers({ children }) { | ||
return <ChakraProvider>{children}</ChakraProvider>; | ||
} |
This file contains 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,11 @@ | ||
import Providers from "./Providers"; | ||
|
||
export default function Layout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<body> | ||
<Providers>{children}</Providers> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains 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,17 @@ | ||
import { Suspense } from "react"; | ||
|
||
import { Button, Spinner } from "./Chakra"; | ||
|
||
async function AsyncComponent() { | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
return null; | ||
} | ||
|
||
export default function Page() { | ||
return ( | ||
<Suspense fallback={<Spinner />}> | ||
<AsyncComponent /> | ||
<Button>Hello Chakra UI!</Button> | ||
</Suspense> | ||
); | ||
} |
This file contains 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,21 @@ | ||
{ | ||
"name": "@lazarv/react-server-example-chakra-ui", | ||
"private": true, | ||
"description": "@lazarv/react-server Chakra UI example application", | ||
"scripts": { | ||
"dev": "react-server", | ||
"build": "react-server build", | ||
"start": "react-server start" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@lazarv/react-server": "workspace:^", | ||
"@lazarv/react-server-router": "workspace:^", | ||
"@chakra-ui/react": "^2.8.2", | ||
"@emotion/react": "^11.13.3", | ||
"@emotion/styled": "^11.13.0", | ||
"framer-motion": "^11.5.4" | ||
} | ||
} |
This file contains 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,22 @@ | ||
export default { | ||
root: "app", | ||
public: "public", | ||
page: { | ||
include: ["**/page.jsx"], | ||
}, | ||
layout: { | ||
include: ["**/layout.jsx"], | ||
}, | ||
build: { | ||
chunkSizeWarningLimit: 1000, | ||
rollupOptions: { | ||
output: { | ||
manualChunks(id) { | ||
if (id.includes("@chakra-ui/react")) { | ||
return "@chakra-ui/react"; | ||
} | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; |
This file contains 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 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 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 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 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 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,15 @@ | ||
import * as sys from "../sys.mjs"; | ||
|
||
const cwd = sys.cwd(); | ||
|
||
export default function asset() { | ||
return { | ||
name: "react-server:asset", | ||
transform(code) { | ||
if (code.startsWith(`export default "/@fs${cwd}`)) { | ||
return code.replace(`export default "/@fs${cwd}`, `export default "`); | ||
} | ||
return null; | ||
}, | ||
}; | ||
} |
Oops, something went wrong.