Skip to content

Commit

Permalink
fix everything
Browse files Browse the repository at this point in the history
  • Loading branch information
LankyMoose committed May 6, 2023
1 parent 5351cef commit 9b1b44d
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 146 deletions.
4 changes: 2 additions & 2 deletions apps/ssr3/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ const sharedSettings = {
Promise.all([
esbuild.build({
sourcemap: "linked",
entryPoints: ["./.cb/src/server/index.ts"],
entryPoints: ["./src/server/index.ts"],
outdir: "dist/server",
platform: "node",
...sharedSettings,
plugins: [generateFileRouter()],
}),
esbuild.build({
entryPoints: ["./.cb/src/client/index.ts"],
entryPoints: ["./src/client/index.ts"],
outdir: "dist/static",
splitting: true,
...sharedSettings,
Expand Down
11 changes: 5 additions & 6 deletions packages/cli/src/build/prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,21 @@ const createFileRouter = (routes) => {
)
const content = `import * as Cinnabun from "../../"
import { Cinnabun as cb, createSignal } from "../../../"
import { Route, Router } from "../"
import { RouteComponent, RouterComponent } from "../"
const pathStore = createSignal(cb.isClient ? window.location.pathname : "/")
var FileRoutes = () => {
return (
<Router store={pathStore}>
return new RouterComponent(pathStore, [
${routeImports
.map(
(r, i) =>
`<Route path="${transformRoutePath(
`new RouteComponent("${transformRoutePath(
pageRoutes[i],
true
)}" component={(props) => Cinnabun.lazy(${r}, props)} />\n `
)}", [(props) => Cinnabun.lazy(${r}, props)]),\n `
)
.join("")}
</Router>
])
)
}`
return content
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/build/transform-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ const generateFileRouter = () => ({

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

console.log("REPLACED", replaced)

return {
contents: replaced,
loader: "jsx",
loader: "js",
}
})
},
Expand Down
12 changes: 1 addition & 11 deletions packages/cli/src/routes/start.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command, Option } from "commander"
import esbuild from "esbuild"
import { generateFileRouter, generateServer } from "../build/transform-plugin"
import { generateFileRouter } from "../build/transform-plugin"

export default new Command("start")
.description("start your cinnabun project")
Expand All @@ -9,16 +9,6 @@ export default new Command("start")
new Option("-h, --host <host>", "host to run on").default("localhost")
)
.action(async ({ port }) => {
// await Promise.all([buildServer(), buildClient()])

/*
export {default as App} from "./src/App.tsx"
export * from "${__dirname}/../build/server.js"
*/
const result = await esbuild.build({
stdin: {
contents: `
Expand Down
5 changes: 5 additions & 0 deletions packages/lib/src/router/generated/fileRouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var FileRoutes = "$FILE_ROUTES"

export const FileRouter = () => {
return FileRoutes
}
6 changes: 0 additions & 6 deletions packages/lib/src/router/generated/fileRouter.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/lib/src/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Cinnabun } from "../cinnabun"
import { DomInterop } from "../domInterop"
import { ComponentChild, PropsSetter, RouteProps } from "../types"

class RouteComponent extends Component<any> {
export class RouteComponent extends Component<any> {
constructor(path: string, component: ComponentChild) {
super("", {
path,
Expand Down
Loading

0 comments on commit 9b1b44d

Please sign in to comment.