feat: --config is not needed anymore (#48)
This commit removes the need for users to specify a --config file. TS libs are now configured via `/// <reference>` directives, and the JSX transform is specified via the `/** @jsx h */` pragma. The future is configless!
This commit is contained in:
@@ -36,4 +36,4 @@ jobs:
|
|||||||
run: deno cache --no-check src/*/deps.ts
|
run: deno cache --no-check src/*/deps.ts
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: deno test -A --unstable --config ./tsconfig.json --no-check
|
run: deno test -A --unstable --no-check
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ fresh init myproject
|
|||||||
To now start the project, call `deno run`:
|
To now start the project, call `deno run`:
|
||||||
|
|
||||||
```
|
```
|
||||||
deno run -A --unstable --config tsconfig.json --watch main.ts
|
deno run -A --unstable --watch main.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
To deploy the script to [Deno Deploy](https://deno.com/deploy), push your
|
To deploy the script to [Deno Deploy](https://deno.com/deploy), push your
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ To learn more about how projects are structured, take a look at the
|
|||||||
You can now run your new project locally using the `deno` CLI:
|
You can now run your new project locally using the `deno` CLI:
|
||||||
|
|
||||||
```
|
```
|
||||||
deno run -A --unstable --config tsconfig.json --watch main.ts
|
deno run -A --unstable --watch main.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
The `--watch` option will cause your script to be reloaded on any changes to the
|
The `--watch` option will cause your script to be reloaded on any changes to the
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
Start the project:
|
Start the project:
|
||||||
|
|
||||||
```
|
```
|
||||||
deno run -A --unstable --config tsconfig.json --watch main.ts
|
deno run -A --unstable --watch main.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
After adding, removing, or moving a page in the `pages` directory, run:
|
After adding, removing, or moving a page in the `pages` directory, run:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h, tw } from "../deps.ts";
|
import { h, tw } from "../deps.ts";
|
||||||
|
|
||||||
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
|
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h, tw } from "../deps.ts";
|
import { h, tw } from "../deps.ts";
|
||||||
|
|
||||||
export function IconMinus() {
|
export function IconMinus() {
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/// <reference no-default-lib="true" />
|
||||||
|
/// <reference lib="dom" />
|
||||||
|
/// <reference lib="deno.ns" />
|
||||||
|
/// <reference lib="deno.unstable" />
|
||||||
|
|
||||||
export * from "../runtime.ts";
|
export * from "../runtime.ts";
|
||||||
import { IS_BROWSER } from "../runtime.ts";
|
import { IS_BROWSER } from "../runtime.ts";
|
||||||
import { setup, tw } from "https://esm.sh/twind";
|
import { setup, tw } from "https://esm.sh/twind";
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h } from "../deps.ts";
|
import { h } from "../deps.ts";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { RoundedButton } from "../components/Button.tsx";
|
import { RoundedButton } from "../components/Button.tsx";
|
||||||
import { IconMinus, IconPlus } from "../components/Icons.tsx";
|
import { IconMinus, IconPlus } from "../components/Icons.tsx";
|
||||||
import { h, IS_BROWSER, tw, useState } from "../deps.ts";
|
import { h, IS_BROWSER, tw, useState } from "../deps.ts";
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h, PageConfig, PageProps, useData } from "../../deps.ts";
|
import { h, PageConfig, PageProps, useData } from "../../deps.ts";
|
||||||
|
|
||||||
export default function ModuleInfoPage({ params }: PageProps) {
|
export default function ModuleInfoPage({ params }: PageProps) {
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["dom", "deno.ns", "deno.unstable"],
|
|
||||||
"jsxFactory": "h",
|
|
||||||
"jsxFragmentFactory": "Fragment"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -5,7 +5,7 @@ lint:
|
|||||||
deno lint
|
deno lint
|
||||||
|
|
||||||
test:
|
test:
|
||||||
deno test --no-check -A --config tsconfig.json
|
deno test --no-check -A
|
||||||
|
|
||||||
watch_example:
|
watch_example:
|
||||||
deno run -A --unstable --config example/tsconfig.json --watch example/main.ts
|
deno run -A --unstable --watch example/main.ts
|
||||||
+11
-19
@@ -63,7 +63,8 @@ async function init(directory: string) {
|
|||||||
import.meta.url,
|
import.meta.url,
|
||||||
)}";\n`;
|
)}";\n`;
|
||||||
await Deno.writeTextFile(join(directory, "deps.ts"), DEPS_TS);
|
await Deno.writeTextFile(join(directory, "deps.ts"), DEPS_TS);
|
||||||
const PAGES_INDEX_TSX = `import { h, IS_BROWSER, useState } from "../deps.ts";
|
const PAGES_INDEX_TSX = `/** @jsx h */
|
||||||
|
import { h, IS_BROWSER, useState } from "../deps.ts";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
return (
|
return (
|
||||||
@@ -97,7 +98,8 @@ function Counter() {
|
|||||||
join(directory, "pages", "index.tsx"),
|
join(directory, "pages", "index.tsx"),
|
||||||
PAGES_INDEX_TSX,
|
PAGES_INDEX_TSX,
|
||||||
);
|
);
|
||||||
const PAGES_GREET_TSX = `import { h } from "../deps.ts";
|
const PAGES_GREET_TSX = `/** @jsx h */
|
||||||
|
import { h } from "../deps.ts";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
params: Record<string, string | string[]>;
|
params: Record<string, string | string[]>;
|
||||||
@@ -136,23 +138,13 @@ export default (_req: Request): Response => {
|
|||||||
join(directory, "pages", "api", "joke.ts"),
|
join(directory, "pages", "api", "joke.ts"),
|
||||||
PAGES_API_JOKE_TS,
|
PAGES_API_JOKE_TS,
|
||||||
);
|
);
|
||||||
const TSCONFIG_JSON = JSON.stringify(
|
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"lib": ["dom", "deno.ns", "deno.unstable"],
|
|
||||||
"jsxFactory": "h",
|
|
||||||
"jsxFragmentFactory": "Fragment",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
undefined,
|
|
||||||
2,
|
|
||||||
) + "\n";
|
|
||||||
await Deno.writeTextFile(
|
|
||||||
join(directory, "tsconfig.json"),
|
|
||||||
TSCONFIG_JSON,
|
|
||||||
);
|
|
||||||
const serverUrl = new URL("../../server.ts", import.meta.url);
|
const serverUrl = new URL("../../server.ts", import.meta.url);
|
||||||
const MAIN_TS = `import { start } from "${serverUrl}";
|
const MAIN_TS = `/// <reference no-default-lib="true" />
|
||||||
|
/// <reference lib="dom" />
|
||||||
|
/// <reference lib="deno.ns" />
|
||||||
|
/// <reference lib="deno.unstable" />
|
||||||
|
|
||||||
|
import { start } from "${serverUrl}";
|
||||||
import routes from "./routes.gen.ts";
|
import routes from "./routes.gen.ts";
|
||||||
|
|
||||||
start(routes);
|
start(routes);
|
||||||
@@ -168,7 +160,7 @@ start(routes);
|
|||||||
Start the project:
|
Start the project:
|
||||||
|
|
||||||
\`\`\`
|
\`\`\`
|
||||||
deno run -A --unstable --config tsconfig.json --watch main.ts
|
deno run -A --unstable --watch main.ts
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
After adding, removing, or moving a page in the \`pages\` directory, run:
|
After adding, removing, or moving a page in the \`pages\` directory, run:
|
||||||
|
|||||||
@@ -36,14 +36,12 @@ export class Bundler {
|
|||||||
bundle: true,
|
bundle: true,
|
||||||
entryPoints,
|
entryPoints,
|
||||||
format: "esm",
|
format: "esm",
|
||||||
jsxFactory: "h",
|
|
||||||
jsxFragment: "Fragment",
|
|
||||||
metafile: true,
|
metafile: true,
|
||||||
minify: true,
|
minify: true,
|
||||||
outdir: `/`,
|
outdir: `/`,
|
||||||
outfile: "",
|
outfile: "",
|
||||||
platform: "neutral",
|
platform: "neutral",
|
||||||
plugins: [freshPlugin(this.#pages), denoPlugin({ loader: "portable" })],
|
plugins: [freshPlugin(this.#pages), denoPlugin()],
|
||||||
splitting: true,
|
splitting: true,
|
||||||
target: ["chrome89", "firefox88", "safari13"],
|
target: ["chrome89", "firefox88", "safari13"],
|
||||||
treeShaking: true,
|
treeShaking: true,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { renderToString } from "./deps.ts";
|
import { renderToString } from "./deps.ts";
|
||||||
import { ComponentChild, h } from "../runtime/deps.ts";
|
import { ComponentChild, h } from "../runtime/deps.ts";
|
||||||
import { DATA_CONTEXT } from "../runtime/hooks.ts";
|
import { DATA_CONTEXT } from "../runtime/hooks.ts";
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
Start the project:
|
Start the project:
|
||||||
|
|
||||||
```
|
```
|
||||||
deno run -A --unstable --config tsconfig.json --watch main.ts
|
deno run -A --unstable --watch main.ts
|
||||||
```
|
```
|
||||||
|
|
||||||
After adding, removing, or moving a page in the `pages` directory, run:
|
After adding, removing, or moving a page in the `pages` directory, run:
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h } from "../deps.ts";
|
import { h } from "../deps.ts";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h, IS_BROWSER, useData } from "../deps.ts";
|
import { h, IS_BROWSER, useData } from "../deps.ts";
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h, PageProps } from "../../deps.ts";
|
import { h, PageProps } from "../../deps.ts";
|
||||||
|
|
||||||
export default function Home(props: PageProps) {
|
export default function Home(props: PageProps) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/** @jsx h */
|
||||||
|
|
||||||
import { h, PageConfig } from "../deps.ts";
|
import { h, PageConfig } from "../deps.ts";
|
||||||
|
|
||||||
export default function StaticPage() {
|
export default function StaticPage() {
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"jsxFactory": "h",
|
|
||||||
"jsxFragmentFactory": "Fragment"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user