Skip to content

Commit

Permalink
handle .client and .server folders
Browse files Browse the repository at this point in the history
  • Loading branch information
rphlmr committed Aug 6, 2024
1 parent b6252f7 commit 54d3b50
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
15 changes: 14 additions & 1 deletion examples/remix-unstable/app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
import { useLoaderData, useRevalidator } from "@remix-run/react";
import { type ClientLoaderFunctionArgs, useLoaderData, useRevalidator } from "@remix-run/react";
import { getPublic } from "~/utils/.client/public";
import { getCommon } from "~/utils/.common/common";
import { getSecret } from "~/utils/.server/secret";
import { getEnv } from "~/utils/env.server";

export function loader() {
console.log(getSecret(), getCommon());
return {
env: getEnv(),
};
}

export async function clientLoader({ serverLoader }: ClientLoaderFunctionArgs) {
console.log(getPublic(), getCommon());
return {
...(await serverLoader<typeof loader>()),
};
}

clientLoader.hydrate = true;

export default function Index() {
const data = useLoaderData<typeof loader>();
const { revalidate } = useRevalidator();
Expand Down
3 changes: 3 additions & 0 deletions examples/remix-unstable/app/utils/.client/public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getPublic() {
return "public";
}
3 changes: 3 additions & 0 deletions examples/remix-unstable/app/utils/.common/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getCommon() {
return "common";
}
3 changes: 3 additions & 0 deletions examples/remix-unstable/app/utils/.server/secret.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getSecret() {
return "secret";
}
8 changes: 7 additions & 1 deletion src/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ export function devServer(config?: HonoDevServerOptions) {
injectClientScript: false,
entry: mergedConfig.entry, // The file path of your server.
export: mergedConfig.exportName,
exclude: [`/${mergedConfig.appDirectory}/**`, /^\/@.+$/, /^\/node_modules\/.*/, ...mergedConfig.exclude],
exclude: [
`/${mergedConfig.appDirectory}/**/*`,
`/${mergedConfig.appDirectory}/**/.*/**`,
/^\/@.+$/,
/^\/node_modules\/.*/,
...mergedConfig.exclude,
],
});
}

0 comments on commit 54d3b50

Please sign in to comment.