Loading...
, 9 | ssr: false, 10 | } 11 | ); 12 | 13 | const Page = () => { 14 | return{JSON.stringify(project.tests.runner.results, null, 2)}
27 |
31 | Edit src/App.tsx and save to test HMR
32 |
35 | Click on the Vite and React logos to learn more 36 |
37 | > 38 | ); 39 | } 40 | 41 | export default App; 42 | -------------------------------------------------------------------------------- /src/templates/library/typescript/files/rollup.config.mjs: -------------------------------------------------------------------------------- 1 | import dts from "rollup-plugin-dts"; 2 | import esbuild from "rollup-plugin-esbuild"; 3 | import fs from "fs"; 4 | 5 | const rawData = fs.readFileSync("./package.json"); 6 | const packageJson = JSON.parse(rawData); 7 | 8 | // Custom Rollup plugin to copy and modify package.json 9 | const copyPackageJson = () => ({ 10 | name: "copy-package-json", 11 | generateBundle() { 12 | const modifiedPackageJson = { 13 | ...packageJson, 14 | main: "index.js", 15 | module: "index.mjs", 16 | typings: "index.d.ts", 17 | }; 18 | this.emitFile({ 19 | type: "asset", 20 | fileName: "package.json", 21 | source: JSON.stringify(modifiedPackageJson, null, 2), 22 | }); 23 | }, 24 | }); 25 | 26 | export default [ 27 | { 28 | input: "index.ts", 29 | output: [ 30 | { 31 | file: "dist/index.js", 32 | format: "cjs", 33 | sourcemap: true, 34 | }, 35 | { 36 | file: "dist/index.mjs", 37 | format: "esm", 38 | sourcemap: true, 39 | }, 40 | ], 41 | plugins: [esbuild(), copyPackageJson()], 42 | }, 43 | { 44 | input: "index.ts", 45 | output: [{ file: "dist/index.d.ts", format: "es" }], 46 | plugins: [dts()], 47 | }, 48 | ]; 49 | -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/projects/PreviewTabs.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | chakra, 3 | Box, 4 | Button, 5 | HStack, 6 | Tab, 7 | TabList, 8 | Tabs, 9 | } from "@chakra-ui/react"; 10 | import { observer } from "mobx-react"; 11 | import { useProject } from "./ProjectProvider"; 12 | 13 | const PREVIEW_TABS = ["example", "tests"]; 14 | 15 | const PreviewTabs = observer(() => { 16 | const project = useProject(); 17 | 18 | return ( 19 |
103 | Edit src/App.tsx and save to test HMR
104 |
107 | Click on the Vite and React logos to learn more 108 |
109 | > 110 | ); 111 | } 112 | 113 | export default App; 114 | `; 115 | }; 116 | 117 | export const getFiles = (options: TemplateOptions) => { 118 | return renderFiles( 119 | { 120 | ...files, 121 | "src/App.tsx": { 122 | code: getAppTsx(options) as string, 123 | }, 124 | }, 125 | { 126 | name: options.name, 127 | } 128 | ); 129 | }; 130 | -------------------------------------------------------------------------------- /src/state/runners/emulator.ts: -------------------------------------------------------------------------------- 1 | import { SpawnOptions, WebContainer } from "@webcontainer/api"; 2 | import { files } from "./emulator-files"; 3 | import { nanoid } from "nanoid"; 4 | import { createAsyncQueue } from "../../lib/async"; 5 | 6 | export type EmulatorFiles = Record