feat: use import maps instead of deps files (#209)

This commit updates fresh to use import maps instead of deps files in generated projects.
This commit is contained in:
Luca Casonato
2022-05-23 19:35:15 +02:00
committed by GitHub
parent fd1346ed6b
commit 80598d07fd
71 changed files with 188 additions and 141 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
/** @jsx h */
import { h, tw } from "../deps.client.ts";
import { h } from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
return (
+3 -1
View File
@@ -1,6 +1,8 @@
/** @jsx h */
import { apply, h, tw } from "../deps.client.ts";
import { h } from "$fresh/runtime.ts";
import { apply, tw } from "../utils/twind.ts";
import {
CATEGORIES,
TableOfContentsCategory,
+2 -1
View File
@@ -1,6 +1,7 @@
/** @jsx h */
import { h, tw } from "../deps.client.ts";
import { h } from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
const LINKS = [
{
+2 -1
View File
@@ -1,6 +1,7 @@
/** @jsx h */
import { h, tw } from "../deps.client.ts";
import { h } from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
export function IconMinus() {
return (
+2 -1
View File
@@ -1,6 +1,7 @@
/** @jsx h */
import { h, tw } from "../deps.client.ts";
import { h } from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
export default function NavigationBar(props: { active: string }) {
const items = [
+2 -1
View File
@@ -1,6 +1,7 @@
/** @jsx h */
import { h, tw } from "../deps.client.ts";
import { h } from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
export default function WarningBanner() {
const warning = tw`bg-yellow-100 border(1 yellow-200) p-4 mb-4`;
+6
View File
@@ -0,0 +1,6 @@
{
"tasks": {
"start": "deno run -A --watch main.ts & deno run -A ../cli.ts manifest --watch"
},
"importMap": "./import_map.json"
}
+7
View File
@@ -0,0 +1,7 @@
{
"imports": {
"$fresh/": "../",
"$twind": "https://esm.sh/twind@0.16.16",
"$twind/": "https://esm.sh/twind@0.16.16/"
}
}
+2 -1
View File
@@ -1,5 +1,6 @@
/** @jsx h */
import { h, IS_BROWSER, tw, useState } from "../deps.client.ts";
import { h, IS_BROWSER, useState } from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
import { RoundedButton } from "../components/Button.tsx";
import { IconMinus, IconPlus } from "../components/Icons.tsx";
+5 -10
View File
@@ -1,12 +1,7 @@
/** @jsx h */
import {
Fragment,
h,
tw,
useEffect,
useRef,
useState,
} from "../deps.client.ts";
/** @jsxFrag Fragment */
import { Fragment, h, useEffect, useRef, useState } from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
import { Spring, WaveTank } from "../components/WaveTank.ts";
function easeInCirc(x: number) {
@@ -99,7 +94,7 @@ function LemonDrop() {
}, []);
return (
<Fragment>
<>
<svg
width="100"
height="300"
@@ -143,7 +138,7 @@ function LemonDrop() {
>
</polygon>
</svg>
</Fragment>
</>
);
}
+1 -1
View File
@@ -4,7 +4,7 @@
/// <reference lib="deno.ns" />
/// <reference lib="deno.unstable" />
import { start } from "./deps.server.ts";
import { start } from "$fresh/server.ts";
import routes from "./fresh.gen.ts";
await start(routes);
+3 -2
View File
@@ -1,7 +1,8 @@
// This module adds twind support.
import { setup, theme } from "../deps.client.ts";
import { RenderContext, RenderFn, virtualSheet } from "../deps.server.ts";
import { RenderContext, RenderFn } from "$fresh/server.ts";
import { setup, theme } from "../utils/twind.ts";
import { virtualSheet } from "$twind/sheets";
const sheet = virtualSheet();
sheet.reset();
+5 -10
View File
@@ -1,16 +1,11 @@
/** @jsx h */
/** @jsxFrag Fragment */
import {
apply,
asset,
Fragment,
h,
Head,
PageProps,
tw,
} from "../../deps.client.ts";
import { frontMatter, gfm, Handlers } from "../../deps.server.ts";
import { Fragment, h, Head, PageProps } from "$fresh/runtime.ts";
import { Handlers } from "$fresh/server.ts";
import { apply, tw } from "../../utils/twind.ts";
import { frontMatter, gfm } from "../../utils/markdown.ts";
import DocsSidebar from "../../components/DocsSidebar.tsx";
import Footer from "../../components/Footer.tsx";
import NavigationBar from "../../components/NavigationBar.tsx";
+2 -1
View File
@@ -1,4 +1,5 @@
import { gfm, Handlers } from "../deps.server.ts";
import { Handlers } from "$fresh/server.ts";
import { gfm } from "../utils/markdown.ts";
// TODO(lucacasonato): hash the file and use the hash as the filename, and serve
// with high-cacheability headers.
+2 -2
View File
@@ -8,8 +8,8 @@ import {
h,
Head,
PageProps,
tw,
} from "../deps.client.ts";
} from "$fresh/runtime.ts";
import { tw } from "../utils/twind.ts";
import Counter from "../islands/Counter.tsx";
import LemonDrop from "../islands/LemonDrop.tsx";
import Footer from "../components/Footer.tsx";
@@ -1,7 +1,3 @@
export * from "../server.ts";
export { virtualSheet } from "https://esm.sh/twind@0.16.16/sheets";
export * as gfm from "https://deno.land/x/gfm@0.1.19/mod.ts";
import "https://esm.sh/prismjs@1.27.0/components/prism-jsx.js?no-check";
import "https://esm.sh/prismjs@1.27.0/components/prism-typescript.js?no-check";
+3 -4
View File
@@ -1,7 +1,6 @@
export * from "../runtime.ts";
import { IS_BROWSER } from "../runtime.ts";
import { apply, setup, tw } from "https://esm.sh/twind@0.16.16";
import * as colors from "https://esm.sh/twind@0.16.16/colors";
import { IS_BROWSER } from "$fresh/runtime.ts";
import { apply, setup, tw } from "$twind";
import * as colors from "$twind/colors";
export { apply, setup, tw };
export const theme = {
colors: {