This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { test, expect } from 'vitest'; | |
import { build, splitVendorChunkPlugin } from 'vite'; | |
import path from 'path'; | |
import { OutputAsset, OutputBundle, OutputChunk, RollupOutput } from 'rollup'; | |
import ts from 'typescript'; | |
const root = path.join(__dirname, "__fixtures") | |
test("nested", async () => { | |
const a = 'export default Math.random()'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {test, expect} from 'vitest'; | |
test("nested", async () => { | |
const a = 'export default Math.random()'; | |
const b = `export default () => import('data:text/javascript;base64,${btoa(a)}')`; | |
const bmod = await import(`data:text/javascript;base64,${btoa(b)}`); | |
const amod = await import(`data:text/javascript;base64,${btoa(a)}`); | |
expect(await bmod.default()).not.toBe(await amod.default); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Grid css layout utilities for [x, y, w, h] grid areas. | |
Example: | |
export default function App() { | |
return ( | |
<> | |
<Grid | |
rows={["32px", "1fr", "1fr", "1fr", "1fr"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let x: Option<Result<(&str, &str), ()>> = Some(Ok(("x", "y"))); | |
// if let | |
if let Some(Ok((a, _))) = x { | |
if a == "x" { | |
println!("a=x"); | |
} | |
} | |
// match | |
match x { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S deno run -A | |
/* | |
$ edit ~/bin/cmd | |
$ chmod +x ~/bin/cmd | |
$ cmd -f | |
# Run | |
$ ls -al | |
total 24 | |
drwxr-xr-x 10 kotaro.chikuba staff 320 Sep 22 20:16 . | |
drwxr-xr-x 9 kotaro.chikuba staff 288 Sep 22 20:01 .git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ts from "typescript"; | |
import { cloneNode } from "ts-clone-node"; | |
import { expect, test } from "vitest"; | |
test("jsx pure adder", async (t) => { | |
const transformer: ts.TransformerFactory<any> = (context) => { | |
return (sourceFile) => { | |
const visitor: ts.Visitor = (node) => { | |
if (ts.isCallExpression(node)) { | |
if (ts.isIdentifier(node.expression) && (node.expression.text === "_jsx" || node.expression.text === "_jsxs")) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/Root.tsx | |
import {useState} from "react"; | |
export default function Root() { | |
const [count, setCount] = useState(0); | |
return <div> | |
<h1>App</h1> | |
<button type="button" onClick={() => setCount(n => n+1)}>{count}</button> | |
</div> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Kysely } from "kysely"; | |
import type { Adapter, AdapterSession, AdapterUser } from "@auth/core/adapters"; | |
import type { Generated, GeneratedAlways } from "kysely"; | |
export interface Database { | |
User: { | |
id: Generated<string>; | |
name: string | null; | |
email: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat test.sql | |
select 1; | |
-- comment; | |
select 2;⏎ | |
$ env WRANGLER_LOG=debug pnpm wrangler d1 execute mydb2 --file test.sql --batch-size 1 | |
-------------------- | |
🚧 D1 is currently in open alpha and is not recommended for production data and traffic | |
🚧 Please report any bugs to https://github.com/cloudflare/workers-sdk/issues/new/choose | |
🚧 To request features, visit https://community.cloudflare.com/c/developers/d1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Miniflare } from "miniflare"; | |
const mf = new Miniflare({ | |
modules: true, | |
script: `export default { | |
async fetch(req, env, ctx) { | |
return new Response("ok"); | |
} | |
} | |
`, | |
d1Persist: true, |