Skip to content

Commit

Permalink
tidy-up
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed May 6, 2023
1 parent 9b1b44d commit 3acb5b8
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions apps/ssr3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@fastify/static": "^6.10.1",
"@fastify/websocket": "^8.0.0",
"cinnabun": "workspace:^",
"cinnabun-cli": "workspace:^",
"esbuild": "^0.17.18",
"fastify": "^4.17.0",
"fastify-plugin": "^4.5.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/build/prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ var FileRoutes = () => {
`new RouteComponent("${transformRoutePath(
pageRoutes[i],
true
)}", [(props) => Cinnabun.lazy(${r}, props)]),\n `
)}", (props) => Cinnabun.lazy(${r}, props)),\n `
)
.join("")}
])
)
}`
return content
}
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/build/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export function createServer(App: ComponentFunc) {
})

app.get("/*", async (req, res) => {
console.log("req.url: ", req.url)
const cinnabunInstance = new Cinnabun()

cinnabunInstance.setServerRequestData({
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/src/build/transform-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ const generateServer = () => ({
const generateFileRouter = () => ({
name: "fileRoute-generator-plugin",
setup(build) {
build.onLoad({ filter: /fileRouter\.js?$/ }, async (args) => {
build.onLoad({ filter: /fileRouter\.ts?$/ }, async (args) => {
const contents = await fs.promises.readFile(args.path, "utf8")

const replaced = contents
.replace("//@ts-expect-error TS2552", "")
.replace('var FileRoutes = "$FILE_ROUTES"', prebuild())

console.log("REPLACED", replaced)

return {
contents: replaced,
loader: "js",
Expand Down
5 changes: 4 additions & 1 deletion packages/cli/src/routes/start.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Command, Option } from "commander"
import esbuild from "esbuild"
import { generateFileRouter } from "../build/transform-plugin"
import path from "path"

export default new Command("start")
.description("start your cinnabun project")
Expand All @@ -13,7 +14,9 @@ export default new Command("start")
stdin: {
contents: `
import {App} from "./src/App"
import {createServer} from "${__dirname}/../build/server.js"
import {createServer} from "${path
.join(__dirname, "..", "build", "server.js")
.replaceAll(path.sep, "/")}"
(() => ({
App,
createServer
Expand Down
4 changes: 3 additions & 1 deletion packages/lib/src/lazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { ComponentProps } from "./types"

export const lazy = (
func: Promise<{ default: any }>,
props: Partial<ComponentProps<any>>
props: Partial<ComponentProps<any>>,
prefetch: boolean = true
) => {
return new SuspenseComponent("", {
promise: async () => func,
prefetch,
children: [
(loading: boolean, res: { default: any }) => {
if (loading) return new FragmentComponent()
Expand Down
1 change: 0 additions & 1 deletion packages/lib/src/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export class SSR {
}

static render(content: string, config: SSRConfig, accumulator: Accumulator) {
console.log("ssr/render", content)
if (config.stream) {
config.stream.write(content)
} else {
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3acb5b8

Please sign in to comment.