Skip to content

Commit e8313e3

Browse files
committed
feat: now can use PranxRouter and select application mode.
fix: remove server css output files
1 parent 97b37aa commit e8313e3

File tree

19 files changed

+152
-104
lines changed

19 files changed

+152
-104
lines changed

examples/basic/pranx.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { PranxConfig } from "pranx";
22

33
export default {
4-
csr: true,
54
esbuild: {},
65
} satisfies PranxConfig;

examples/basic/src/App.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
import { PranxRouter } from "pranx/client";
12
import type { PropsWithChildren } from "preact/compat";
23
import { UserProvider } from "./context/user-context";
34
import "./styles/styles.css";
45

5-
export function App(props: PropsWithChildren) {
6-
return <UserProvider>{props.children}</UserProvider>;
6+
export default function App(props: PropsWithChildren) {
7+
return (
8+
<UserProvider>
9+
<PranxRouter mode="spa" />
10+
{props.children}
11+
</UserProvider>
12+
);
713
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import { mount, StartApp } from "pranx/client";
2-
import { App } from "./App";
1+
import { mount } from "pranx/client";
2+
import App from "./App";
33

4-
mount(
5-
<App>
6-
<StartApp />
7-
</App>,
8-
document.body
9-
);
4+
mount(<App />, document.body);

examples/basic/src/entry-server.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ServerEntryProps } from "pranx";
22
import { Meta, Scripts } from "pranx/server";
3-
import { App } from "./App";
3+
import App from "./App";
44

55
export default function ServerEntry({ children }: ServerEntryProps) {
66
return (

packages/pranx/FEATURES.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# FEATURES ROADMAP
2+
3+
-[X] FSR (File-System-Routing)
4+
-[X] SSR (Server Side Rendering)
5+
-[X] SSG (Static Side Generation)
6+
-[X] Hydratation (Full)
7+
-[X] CSR (Client-Side-Routing)
8+
-[X] API routes for server endpoints
9+
-[X] Extendable user config
10+
-[ ] ISG (Incremental Static Side Generation)
11+
-[ ] Per page Metadata
12+
-[ ] Client Metadata manipulation
13+
-[ ] Dev Mode
14+
-[ ] Sass Plugin
15+
-[ ] Tailwindcss support v3
16+
-[X] Tailwindcss support v4
17+
-[X] Css modules support
18+
-[ ] Layouts
19+
-[ ] Custom Error Pages
20+
-[ ] Websockets
21+
-[ ] Graphql

packages/pranx/biome.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
}
2020
},
2121
"files": {
22-
"includes": [
23-
"src/**/*",
24-
"!dist/**/*",
25-
"!src/client/shared/exec-match.ts",
26-
"!**/node_modules/**/*"
27-
]
22+
"includes": ["src/**/*", "!dist/**/*", "!**/node_modules/**/*"]
2823
}
2924
}

packages/pranx/src/build/bundle/browser.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export async function bundle_browser(options: { optimize: boolean; user_config:
6565

6666
define: {
6767
...(options.user_config.esbuild?.define || {}),
68-
"window.pranx.csr_enabled": String(options.user_config.csr),
6968
},
7069

7170
plugins: [

packages/pranx/src/build/bundle/server.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { mdx_pranx_plugin } from "@/plugins/mdx-plugin";
22
import { tailwindcss_plugin } from "@/plugins/tailwind-plugin";
33
import esbuild from "esbuild";
4+
import fse from "fs-extra";
45
import { glob } from "glob";
56
import { join } from "pathe";
67
import type { PranxConfig } from "types/index";
@@ -11,6 +12,7 @@ export async function bundle_server(options: { optimize: boolean; user_config: P
1112
[
1213
join(SOURCE_PAGES_DIR, "**/*{page,route}.{js,ts,tsx,jsx}"),
1314
join(SOURCE_DIR, "entry-server.{tsx,jsx}"),
15+
join(SOURCE_DIR, "App.{tsx,jsx}"),
1416
],
1517
{
1618
nodir: true,
@@ -74,5 +76,14 @@ export async function bundle_server(options: { optimize: boolean; user_config: P
7476
],
7577
});
7678

79+
const css_emited = await glob([join(OUTPUT_BUNDLE_SERVER_DIR, "**/*.css")], {
80+
nodir: true,
81+
absolute: true,
82+
});
83+
84+
for (const css_path of css_emited) {
85+
await fse.remove(css_path);
86+
}
87+
7788
return server_bundle_result;
7889
}

packages/pranx/src/client/app-context.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const AppContextProvider = (props: PropsWithChildren) => {
8585

8686
export const _useAppContext = () => {
8787
const c = useContext(_app_context);
88-
if (!c) throw new Error("useAppContext must be used within a AppContextProvider");
88+
if (!c) throw new Error("_useAppContext must be used within a AppContextProvider");
8989
return c;
9090
};
9191

packages/pranx/src/client/components/link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>((props, forwardedRe
1010
throw new Error("Link element must provide a `to` property");
1111
}
1212

13-
if (typeof window !== "undefined" && window.pranx.csr_enabled === true) {
13+
if (typeof window !== "undefined" && window.pranx.router_mode === "spa") {
1414
const { set } = _useAppContext();
1515
return (
1616
<a

0 commit comments

Comments
 (0)