chore: rename *_deps.ts -> deps.*.ts (#206)

As per David's suggestion.
This commit is contained in:
Luca Casonato
2022-05-23 16:05:33 +02:00
committed by GitHub
parent f9f0125282
commit fd6724c050
57 changed files with 70 additions and 70 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ used to pass arbituary data to downstream (or upstream) handlers.
```ts
// routes/_middleware.ts
import { MiddlewareHandlerContext } from "../server_deps.ts";
import { MiddlewareHandlerContext } from "../deps.server.ts";
interface State {
data: string;
+4 -4
View File
@@ -22,7 +22,7 @@ Let's look at a basic route that returns a plain text string:
```tsx
// routes/plain.tsx
import { HandlerContext, Handlers } from "../server_deps.ts";
import { HandlerContext, Handlers } from "../deps.server.ts";
export const handler: Handlers = {
GET(ctx: HandlerContext) {
@@ -43,7 +43,7 @@ Now, let's render some HTML using the route component. Another example:
// routes/html.tsx
/** @jsx h */
import { h, PageProps } from "../client_deps.ts";
import { h, PageProps } from "../deps.client.ts";
export default function Page(props: PageProps) {
return <div>You are on the page '{props.url.href}'.</div>;
@@ -65,8 +65,8 @@ response after rendering the page component.
// routes/html.tsx
/** @jsx h */
import { h, PageProps } from "../client_deps.ts";
import { HandlerContext, Handlers } from "../server_deps.ts";
import { h, PageProps } from "../deps.client.ts";
import { HandlerContext, Handlers } from "../deps.server.ts";
export const handler: Handlers = {
GET(ctx: HandlerContext) {
+2 -2
View File
@@ -31,7 +31,7 @@ Here is an example of an island component that counts down to a specific time.
// islands/Countdown.tsx
/** @jsx h */
import { h, useEffect, useMemo, useState } from "../client_deps.ts";
import { h, useEffect, useMemo, useState } from "../deps.client.ts";
const timeFmt = new Intl.RelativeTimeFormat("en-US");
@@ -73,7 +73,7 @@ client with the correct props:
// routes/countdown.tsx
/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
import { Countdown } from "../islands/Countdown.tsx";
export default function Page() {
+2 -2
View File
@@ -29,11 +29,11 @@ files, only two are strictly necessary for a fresh project:
In addition to these two files, two other files are created that manage
dependencies:
- **`client_deps.ts`**: This file contains dependencies that you need on the
- **`deps.client.ts`**: This file contains dependencies that you need on the
client, and possibly also on the server. It should be assumed that all of the
dependencies referenced by this file will be shipped to the client. By
default, it just re-exports the `fresh` runtime.
- **`server_deps.ts`**: This file contains dependencies that are only used on
- **`deps.server.ts`**: This file contains dependencies that are only used on
the server. These are often things like database drivers, API clients, or
other code that should only be executed on the server. This file should never
be referenced by modules that might be shipped to the client. By default this
+1 -1
View File
@@ -38,7 +38,7 @@ This is done with JSX.
// routes/about.tsx
/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
export default function AboutPage() {
return (
+2 -2
View File
@@ -31,7 +31,7 @@ then adds a custom header to the response before returning it:
// routes/about.tsx
/** @jsx h */
import { h, Handlers } from "../client_deps.ts";
import { h, Handlers } from "../deps.client.ts";
export const handler: Handlers = {
GET(req, ctx) {
@@ -58,7 +58,7 @@ response:
```ts
// routes/api/random-uuid.ts
import { Handlers } from "../client_deps.ts";
import { Handlers } from "../deps.client.ts";
export const handler: Handlers = {
GET(req) {
+1 -1
View File
@@ -28,7 +28,7 @@ as arguments in it's `props` object though.
// routes/greet/[name].tsx
/** @jsx h */
import { h, PageProps } from "../../client_deps.ts";
import { h, PageProps } from "../../deps.client.ts";
export default function AboutPage(props: PageProps) {
const { name } = props.params;
+2 -2
View File
@@ -24,8 +24,8 @@ renders it in a page component.
// routes/github/[username].tsx
/** @jsx h */
import { h, PageProps } from "../../client_deps.ts";
import { Handlers } from "../../server_deps.ts";
import { h, PageProps } from "../../deps.client.ts";
import { Handlers } from "../../deps.server.ts";
interface User {
login: string;
+2 -2
View File
@@ -33,8 +33,8 @@ server side:
// routes/search.tsx
/** @jsx h */
import { h, PageProps } from "../../client_deps.ts";
import { Handlers } from "../../server_deps.ts";
import { h, PageProps } from "../../deps.client.ts";
import { Handlers } from "../../deps.server.ts";
const NAMES = ["Alice", "Bob", "Charlie", "Dave", "Eve", "Frank"];
+3 -3
View File
@@ -17,8 +17,8 @@ your application. All routes can act as both API endpoints and dynamic HTML
pages. More info about how the `routes` subdirectory works can be found on the
[file system routing](./file-system-routing.md) page.
Finally there is a `client_deps.ts` and `server_deps.ts`. These files are the
central location for all external imports. The `client_deps.ts` file is used for
Finally there is a `deps.client.ts` and `deps.server.ts`. These files are the
central location for all external imports. The `deps.client.ts` file is used for
runtime dependencies (ones that are used both in routes and islands), and the
`server_deps.ts` file is used for server only dependencies (for example ones
`deps.server.ts` file is used for server only dependencies (for example ones
used in API routes or middleware).
+1 -1
View File
@@ -1,5 +1,5 @@
/** @jsx h */
import { h, IS_BROWSER, useState } from "../client_deps.ts";
import { h, IS_BROWSER, useState } from "../deps.client.ts";
interface CounterProps {
start: number;
+1 -1
View File
@@ -4,7 +4,7 @@
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { start } from "./server_deps.ts";
import { start } from "./deps.server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
+1 -1
View File
@@ -1,5 +1,5 @@
/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
import Counter from "../islands/Counter.tsx";
export default function Home() {
+9 -9
View File
@@ -66,19 +66,19 @@ async function init(directory: string) {
await Deno.mkdir(join(directory, "islands"), { recursive: true });
await Deno.mkdir(join(directory, "static"), { recursive: true });
const CLIENT_DEPS_TS = `export * from "${new URL(
const DEPS_CLIENT_TS = `export * from "${new URL(
"../../runtime.ts",
import.meta.url,
)}";\n`;
await Deno.writeTextFile(join(directory, "client_deps.ts"), CLIENT_DEPS_TS);
const SERVER_DEPS_TS = `export * from "${new URL(
await Deno.writeTextFile(join(directory, "deps.client.ts"), DEPS_CLIENT_TS);
const DEPS_SERVER_TS = `export * from "${new URL(
"../../server.ts",
import.meta.url,
)}";\n`;
await Deno.writeTextFile(join(directory, "server_deps.ts"), SERVER_DEPS_TS);
await Deno.writeTextFile(join(directory, "deps.server.ts"), DEPS_SERVER_TS);
const ROUTES_INDEX_TSX = `/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
import Counter from "../islands/Counter.tsx";
export default function Home() {
@@ -100,7 +100,7 @@ export default function Home() {
);
const ISLANDS_COUNTER_TSX = `/** @jsx h */
import { h, IS_BROWSER, useState } from "../client_deps.ts";
import { h, IS_BROWSER, useState } from "../deps.client.ts";
interface CounterProps {
start: number;
@@ -127,7 +127,7 @@ export default function Counter(props: CounterProps) {
);
const ROUTES_GREET_TSX = `/** @jsx h */
import { h, PageProps } from "../client_deps.ts";
import { h, PageProps } from "../deps.client.ts";
export default function Greet(props: PageProps) {
return <div>Hello {props.params.name}</div>;
@@ -139,7 +139,7 @@ export default function Greet(props: PageProps) {
);
const ROUTES_API_JOKE_TS =
`import { HandlerContext } from "../../server_deps.ts";
`import { HandlerContext } from "../../deps.server.ts";
// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
const JOKES = [
@@ -188,7 +188,7 @@ export const handler = (_req: Request, _ctx: HandlerContext): Response => {
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { start } from "./server_deps.ts";
import { start } from "./deps.server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
+2 -2
View File
@@ -61,7 +61,7 @@ Deno.test({
"name": tmpDirName,
"contents": [
{ "type": "file", "name": "README.md" },
{ "type": "file", "name": "client_deps.ts" },
{ "type": "file", "name": "deps.client.ts" },
{ "type": "file", "name": "fresh.gen.ts" },
{
"type": "directory",
@@ -86,7 +86,7 @@ Deno.test({
{ "type": "file", "name": "index.tsx" },
],
},
{ "type": "file", "name": "server_deps.ts" },
{ "type": "file", "name": "deps.server.ts" },
{
"type": "directory",
"name": "static",
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
export default function Test(props: { message: string }) {
return (
+1 -1
View File
@@ -1,4 +1,4 @@
import { start } from "./server_deps.ts";
import { start } from "./deps.server.ts";
import routes from "./fresh.gen.ts";
await start(routes);
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
interface Props {
params: Record<string, string | string[]>;
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, UnknownPageProps } from "../client_deps.ts";
import { h, UnknownPageProps } from "../deps.client.ts";
export default function NotFoundPage({ url }: UnknownPageProps) {
return <p>404 not found: {url.pathname}</p>;
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { ErrorPageProps, h } from "../client_deps.ts";
import { ErrorPageProps, h } from "../deps.client.ts";
export default function Error500Page({ error }: ErrorPageProps) {
return <p>500 internal error: {(error as Error).message}</p>;
+1 -1
View File
@@ -1,7 +1,7 @@
/** @jsx h */
/** @jsxFrag Fragment */
import { AppProps, Fragment, h, Head } from "../client_deps.ts";
import { AppProps, Fragment, h, Head } from "../deps.client.ts";
export default function App(props: AppProps) {
return (
+1 -1
View File
@@ -1,4 +1,4 @@
import { MiddlewareHandlerContext } from "../server_deps.ts";
import { MiddlewareHandlerContext } from "../deps.server.ts";
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
ctx.state.root = "root_mw";
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { asset, h } from "../../client_deps.ts";
import { asset, h } from "../../deps.client.ts";
import Test from "../../islands/Test.tsx";
export default function Home() {
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, PageProps, RouteConfig } from "../../client_deps.ts";
import { h, PageProps, RouteConfig } from "../../deps.client.ts";
export default function Page(props: PageProps) {
return <div>Book {props.params.id}</div>;
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, IS_BROWSER } from "../client_deps.ts";
import { h, IS_BROWSER } from "../deps.client.ts";
import Test from "../islands/Test.tsx";
export default function Home() {
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
import { HandlerContext } from "../../../server.ts";
export default function Page() {
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, PageProps } from "../client_deps.ts";
import { h, PageProps } from "../deps.client.ts";
import { HandlerContext, Handlers } from "../../../server.ts";
interface Data extends Record<string, unknown> {
@@ -1,4 +1,4 @@
import { MiddlewareHandlerContext } from "../../server_deps.ts";
import { MiddlewareHandlerContext } from "../../deps.server.ts";
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
ctx.state.layer1 = "layer1_mw";
@@ -1,4 +1,4 @@
import { MiddlewareHandlerContext } from "../../../server_deps.ts";
import { MiddlewareHandlerContext } from "../../../deps.server.ts";
interface State {
root: string;
@@ -1,4 +1,4 @@
import { MiddlewareHandlerContext } from "../../../../server_deps.ts";
import { MiddlewareHandlerContext } from "../../../../deps.server.ts";
export async function handler(_req: Request, ctx: MiddlewareHandlerContext) {
ctx.state.layer3 = "layer3_mw";
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, RouteConfig } from "../client_deps.ts";
import { h, RouteConfig } from "../deps.client.ts";
import { HandlerContext } from "../../../server.ts";
export const handler = {
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, PageProps } from "../../client_deps.ts";
import { h, PageProps } from "../../deps.client.ts";
export default function Home(props: PageProps) {
return <div>{JSON.stringify(props)}</div>;
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { asset, h } from "../client_deps.ts";
import { asset, h } from "../deps.client.ts";
export default function StaticPage() {
return (
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, PageProps, RouteConfig } from "../client_deps.ts";
import { h, PageProps, RouteConfig } from "../deps.client.ts";
export default function WildcardPage({ params }: PageProps) {
if (typeof params.path === "string") {
+1 -1
View File
@@ -4,7 +4,7 @@
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { start } from "./server_deps.ts";
import { start } from "./deps.server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
+1 -1
View File
@@ -1,5 +1,5 @@
/** @jsx h */
import { h } from "../client_deps.ts";
import { h } from "../deps.client.ts";
export default function Home(): null {
throw new Error("boom!");
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, tw } from "../client_deps.ts";
import { h, tw } from "../deps.client.ts";
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
return (
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { apply, h, tw } from "../client_deps.ts";
import { apply, h, tw } from "../deps.client.ts";
import {
CATEGORIES,
TableOfContentsCategory,
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, tw } from "../client_deps.ts";
import { h, tw } from "../deps.client.ts";
const LINKS = [
{
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, tw } from "../client_deps.ts";
import { h, tw } from "../deps.client.ts";
export function IconMinus() {
return (
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, tw } from "../client_deps.ts";
import { h, tw } from "../deps.client.ts";
export default function NavigationBar(props: { active: string }) {
const items = [
+1 -1
View File
@@ -1,6 +1,6 @@
/** @jsx h */
import { h, tw } from "../client_deps.ts";
import { h, tw } from "../deps.client.ts";
export default function WarningBanner() {
const warning = tw`bg-yellow-100 border(1 yellow-200) p-4 mb-4`;
+1 -1
View File
@@ -1,5 +1,5 @@
/** @jsx h */
import { h, IS_BROWSER, tw, useState } from "../client_deps.ts";
import { h, IS_BROWSER, tw, useState } from "../deps.client.ts";
import { RoundedButton } from "../components/Button.tsx";
import { IconMinus, IconPlus } from "../components/Icons.tsx";
+1 -1
View File
@@ -6,7 +6,7 @@ import {
useEffect,
useRef,
useState,
} from "../client_deps.ts";
} from "../deps.client.ts";
import { Spring, WaveTank } from "../components/WaveTank.ts";
function easeInCirc(x: number) {
+1 -1
View File
@@ -4,7 +4,7 @@
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { start } from "./server_deps.ts";
import { start } from "./deps.server.ts";
import routes from "./fresh.gen.ts";
await start(routes);
+2 -2
View File
@@ -1,7 +1,7 @@
// This module adds twind support.
import { setup, theme } from "../client_deps.ts";
import { RenderContext, RenderFn, virtualSheet } from "../server_deps.ts";
import { setup, theme } from "../deps.client.ts";
import { RenderContext, RenderFn, virtualSheet } from "../deps.server.ts";
const sheet = virtualSheet();
sheet.reset();
+2 -2
View File
@@ -9,8 +9,8 @@ import {
Head,
PageProps,
tw,
} from "../../client_deps.ts";
import { frontMatter, gfm, Handlers } from "../../server_deps.ts";
} from "../../deps.client.ts";
import { frontMatter, gfm, Handlers } from "../../deps.server.ts";
import DocsSidebar from "../../components/DocsSidebar.tsx";
import Footer from "../../components/Footer.tsx";
import NavigationBar from "../../components/NavigationBar.tsx";
+1 -1
View File
@@ -1,4 +1,4 @@
import { gfm, Handlers } from "../server_deps.ts";
import { gfm, Handlers } from "../deps.server.ts";
// TODO(lucacasonato): hash the file and use the hash as the filename, and serve
// with high-cacheability headers.
+1 -1
View File
@@ -9,7 +9,7 @@ import {
Head,
PageProps,
tw,
} from "../client_deps.ts";
} from "../deps.client.ts";
import Counter from "../islands/Counter.tsx";
import LemonDrop from "../islands/LemonDrop.tsx";
import Footer from "../components/Footer.tsx";