chore: improve bundling + refactor router (#10)

This commit changes how bundling works, by bundling all routes at once.
Static JS assets are now cached immutably.

Additionally this PR completly refactors how the router works to make it
more modular. This allows users to opt out of the default oak server,
and instead create their own.
This commit is contained in:
Luca Casonato
2021-06-01 23:19:33 +02:00
committed by GitHub
parent 8a58fe7ae0
commit 31dbd99bea
19 changed files with 249 additions and 92 deletions
+2 -3
View File
@@ -1,5 +1,5 @@
# fresh project
### Usage
Install deployctl:
@@ -11,7 +11,7 @@ deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no
Start the project:
```
deployctl run --no-check --watch server.ts
deployctl run --no-check --watch main.ts
```
After adding, removing, or moving a page in the `pages` directory, run:
@@ -19,4 +19,3 @@ After adding, removing, or moving a page in the `pages` directory, run:
```
fresh routes
```
+4
View File
@@ -0,0 +1,4 @@
import { start } from "../server.ts";
import routes from "./routes.gen.ts";
start(routes);
+1 -3
View File
@@ -1,9 +1,7 @@
import { h } from "../deps.ts";
interface Props {
params: {
name: string;
};
params: Record<string, string | string[]>;
}
export default function Greet(props: Props) {
+9 -3
View File
@@ -1,10 +1,16 @@
// DO NOT EDIT. This file is generated by `fresh`.
// This file SHOULD be checked into source version control.
// To update this file, run `fresh routes`.
import { setup } from "../server.ts";
import * as $0 from "./pages/[name].tsx";
import * as $1 from "./pages/index.tsx";
setup([[$0, "./pages/[name].tsx"], [$1, "./pages/index.tsx"]], import.meta.url);
const routes = {
pages: {
"./pages/[name].tsx": $0,
"./pages/index.tsx": $1,
},
baseUrl: import.meta.url,
};
export default routes;
+1 -1
View File
@@ -3,4 +3,4 @@
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
}
}
}