View rewrite-ts.js
/* | |
Patch typescript to run in snowpack. | |
I added this workaround for perf_hooks. | |
Add this task in package.json | |
"scripts": { | |
// ... | |
"postinstall": "node scripts/rewrite-ts.js", | |
} | |
*/ |
View svelte-ssr-css.ts
import { GENERATED_CSS_PREFIX } from "./constants"; | |
import * as uniroll from "uniroll"; | |
import ts from "typescript"; | |
import { svelte } from "./index"; | |
import fetch from "isomorphic-unfetch"; | |
import vm from "vm"; | |
import fs from "fs"; | |
global.fetch = fetch; |
View svelte-ssr-test.ts
import * as uniroll from "uniroll"; | |
import ts from "typescript"; | |
import { svelte } from "rollup-plugin-uniroll-svelte"; | |
import fetch from "isomorphic-unfetch"; | |
import vm from "vm"; | |
global.fetch = fetch; | |
const App = ` | |
<script lang="ts"> | |
export let foo: string; |
View printTemplate.ts
import { ExtendedTemplateNode } from "../../types"; | |
import * as compiler from "svelte/compiler"; | |
// import ts from "typescript"; | |
import prettier from "prettier/standalone"; | |
// @ts-ignore | |
import * as sveltePlugin from "prettier-plugin-svelte"; | |
import * as astring from "astring"; | |
// @ts-ignore |
View printTemplate.ts
import prettier from "prettier/standalone"; | |
import produce from "immer"; | |
import { parse } from "svelte/compiler"; | |
import type { Ast } from "svelte/types/compiler/interfaces"; | |
// @ts-ignore | |
import * as sveltePlugin from "prettier-plugin-svelte"; | |
function printTemplate(ast: Ast) { | |
const overridePlugin = produce(sveltePlugin, (d: any) => { | |
d.parsers.svelte.parse = () => { |
View loadExternalLibTypes.ts
// esm.sh の x-typescript-types を返すだけのエンドポイントのラッパー | |
import { getTypes } from "../pages/api/types"; | |
import type * as Monaco from "monaco-editor"; | |
import path from "path"; | |
import { kvsIndexedDB } from "@kvs/indexeddb"; | |
import ts from "typescript"; | |
type Ctx = { | |
monaco: typeof Monaco; | |
extractImportSpecifiers: (code: string) => Promise<string[]>; |
View getComponentProps.ts
import ts from "typescript"; | |
import { preprocess } from "svelte/compiler"; | |
import { PreprocessorGroup } from "svelte/types/compiler/preprocess/types"; | |
export async function getComponentProps(code: string) { | |
let interfaces: Array<{ | |
identifier: string; | |
type: "number" | "string" | "boolean"; | |
comment?: string; | |
}> = []; |
View getComponentProps.ts
import { PreprocessorGroup } from "svelte/types/compiler/preprocess"; | |
import ts from "typescript"; | |
import { preprocess } from "svelte/compiler"; | |
async function getComponentProps(code: string) { | |
let interfaces: Array<{ | |
identifier: string; | |
type: "number" | "string" | "boolean"; | |
comment?: string; | |
}> = []; |
View run.ts
import { PrismaClient } from "@prisma/client"; | |
import { minifyCode, expandCode, calcHash } from "../src/lib/minifier"; | |
import { v4 as uuid } from "uuid"; | |
async function createSnippet(authorId: string, files: { [k: string]: string }) { | |
const snippetId = uuid(); | |
return await prisma.snippet.create({ | |
data: { | |
id: snippetId, | |
title: "test-snippet", |
View log
prisma:info Starting a sqlite pool with 17 connections. | |
prisma:info Started http server on http+unix:///private/tmp/prisma-789c342c854e2e3b622ab519.sock | |
prisma:query BEGIN | |
prisma:query SELECT `dev`.`User`.`id` FROM `dev`.`User` WHERE `dev`.`User`.`name` = ? LIMIT ? OFFSET ? | |
prisma:query SELECT `dev`.`User`.`id` FROM `dev`.`User` WHERE `dev`.`User`.`name` = ? | |
prisma:query UPDATE `dev`.`User` SET `name` = ? WHERE `dev`.`User`.`id` IN (?) | |
prisma:query SELECT `dev`.`User`.`id`, `dev`.`User`.`name` FROM `dev`.`User` WHERE `dev`.`User`.`id` = ? LIMIT ? OFFSET ? | |
prisma:query COMMIT | |
prisma:query BEGIN | |
prisma:query SELECT `dev`.`User`.`id` FROM `dev`.`User` WHERE `dev`.`User`.`id` = ? LIMIT ? OFFSET ? |
NewerOlder