Skip to content

Commit 34fc551

Browse files
authored
chore: update twind import map defaults in init.ts (#291)
1 parent a2c97fd commit 34fc551

File tree

15 files changed

+37
-28
lines changed

15 files changed

+37
-28
lines changed

.vscode/import_map.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
".": "THIS FILE EXISTS ONLY FOR VSCODE! IT IS NOT USED AT RUNTIME.",
33
"imports": {
44
"$fresh/": "../",
5-
"$twind": "https://esm.sh/twind@0.16.16",
6-
"$twind/": "https://esm.sh/twind@0.16.16/",
5+
6+
"@twind": "../www/utils/twind.ts",
7+
"twind": "https://esm.sh/twind@0.16.16",
8+
"twind/": "https://esm.sh/twind@0.16.16/",
79

810
"preact": "https://esm.sh/preact@10.8.1",
911
"preact/": "https://esm.sh/preact@10.8.1/",

init.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,16 @@ const importMap = {
9191
} as Record<string, string>,
9292
};
9393
if (useTwind) {
94-
importMap.imports["$twind"] = "https://esm.sh/twind@0.16.17";
95-
importMap.imports["$twind/"] = "https://esm.sh/twind@0.16.17/";
96-
importMap.imports["twind"] = "./utils/twind.ts";
94+
importMap.imports["@twind"] = "./utils/twind.ts";
95+
importMap.imports["twind"] = "https://esm.sh/twind@0.16.17";
96+
importMap.imports["twind/"] = "https://esm.sh/twind@0.16.17/";
9797
}
9898
const IMPORT_MAP_JSON = JSON.stringify(importMap, null, 2) + "\n";
9999
await Deno.writeTextFile(join(directory, "import_map.json"), IMPORT_MAP_JSON);
100100

101101
let ROUTES_INDEX_TSX = `/** @jsx h */
102102
import { h } from "preact";\n`;
103-
if (useTwind) ROUTES_INDEX_TSX += `import { tw } from "twind";\n`;
103+
if (useTwind) ROUTES_INDEX_TSX += `import { tw } from "@twind";\n`;
104104
ROUTES_INDEX_TSX += `import Counter from "../islands/Counter.tsx";
105105
106106
export default function Home() {
@@ -129,7 +129,7 @@ let ISLANDS_COUNTER_TSX = `/** @jsx h */
129129
import { h } from "preact";
130130
import { useState } from "preact/hooks";
131131
import { IS_BROWSER } from "$fresh/runtime.ts";
132-
${useTwind ? 'import { tw } from "twind";\n' : ""}
132+
${useTwind ? 'import { tw } from "@twind";\n' : ""}
133133
interface CounterProps {
134134
start: number;
135135
}
@@ -222,8 +222,8 @@ await Deno.writeTextFile(
222222
);
223223

224224
const UTILS_TWIND_TS = `import { IS_BROWSER } from "$fresh/runtime.ts";
225-
import { Configuration, setup } from "$twind";
226-
export * from "$twind";
225+
import { Configuration, setup } from "twind";
226+
export * from "twind";
227227
export const config: Configuration = {
228228
darkMode: "class",
229229
mode: "silent",
@@ -275,8 +275,8 @@ import manifest from "./fresh.gen.ts";
275275

276276
if (useTwind) {
277277
MAIN_TS += `
278-
import { virtualSheet } from "$twind/sheets";
279-
import { config, setup } from "twind";
278+
import { config, setup } from "@twind";
279+
import { virtualSheet } from "twind/sheets";
280280
281281
const sheet = virtualSheet();
282282
sheet.reset();

www/components/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22
import { h } from "preact";
3-
import { tw } from "../utils/twind.ts";
3+
import { tw } from "@twind";
44

55
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
66
return (

www/components/DocsSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22
import { h } from "preact";
3-
import { apply, tw } from "../utils/twind.ts";
3+
import { apply, tw } from "@twind";
44

55
import {
66
CATEGORIES,

www/components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22
import { h } from "preact";
3-
import { tw } from "../utils/twind.ts";
3+
import { tw } from "@twind";
44

55
const LINKS = [
66
{

www/components/Icons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22
import { h } from "preact";
3-
import { tw } from "../utils/twind.ts";
3+
import { tw } from "@twind";
44

55
export function IconMinus() {
66
return (

www/components/NavigationBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22
import { h } from "preact";
3-
import { tw } from "../utils/twind.ts";
3+
import { tw } from "@twind";
44

55
export default function NavigationBar(props: { active: string }) {
66
const items = [

www/components/WarningBanner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @jsx h */
22
import { h } from "preact";
3-
import { tw } from "../utils/twind.ts";
3+
import { tw } from "@twind";
44

55
export default function WarningBanner() {
66
const warning = tw`bg-yellow-100 border(1 yellow-200) p-4 mb-4`;

www/import_map.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
22
"imports": {
33
"$fresh/": "../",
4-
"$twind": "https://esm.sh/twind@0.16.16",
5-
"$twind/": "https://esm.sh/twind@0.16.16/",
4+
5+
"@twind": "./utils/twind.ts",
6+
"twind": "https://esm.sh/twind@0.16.16",
7+
"twind/": "https://esm.sh/twind@0.16.16/",
8+
69
"preact": "https://esm.sh/preact@10.8.1",
710
"preact/": "https://esm.sh/preact@10.8.1/",
811
"preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?deps=preact@10.8.1",
12+
913
"$semver/": "https://deno.land/x/semver@v1.4.0/"
1014
}
1115
}

www/islands/Counter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { h } from "preact";
33
import { useState } from "preact/hooks";
44
import { IS_BROWSER } from "$fresh/runtime.ts";
5-
import { tw } from "../utils/twind.ts";
5+
import { tw } from "@twind";
66
import { RoundedButton } from "../components/Button.tsx";
77
import { IconMinus, IconPlus } from "../components/Icons.tsx";
88

0 commit comments

Comments
 (0)