Skip to content

Commit 300e033

Browse files
committed
Add example vanilla TS app
1 parent 37a13d7 commit 300e033

19 files changed

+133
-13
lines changed

examples/react/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"type": "module",
44
"scripts": {
55
"build": "vite build",
6-
"dev": "vite"
6+
"dev": "vite",
7+
"typecheck": "tsc"
78
},
89
"devDependencies": {
910
"@tanstack/react-query": "^4.29.12",

examples/react/src/app.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2+
import React, { useState } from 'react';
3+
import ReactDOM from 'react-dom/client';
4+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
5+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
6+
var queryClient = new QueryClient();
7+
function App() {
8+
var _a = useState(0), count = _a[0], setCount = _a[1];
9+
return (_jsxs("div", { className: 'App', children: [_jsx("h1", { children: "Example (React)" }), _jsx("p", { children: "The following app includes React Query DevTools (see below) to assert that this plugin does not conflict with it." }), _jsx("p", { children: "Here is a dynamic counter to test that React works as expected." }), _jsx("p", { children: _jsxs("button", { onClick: function () { return setCount(function (count) { return count + 1; }); }, children: ["count is ", count] }) }), _jsxs("p", { children: ["The following text is encoded and decoded with Buffer: ", Buffer.from('Hello!').toString()] })] }));
10+
}
11+
export var app = function () {
12+
ReactDOM.createRoot(document.getElementById('react-app')).render(_jsx(React.StrictMode, { children: _jsxs(QueryClientProvider, { client: queryClient, children: [_jsx(App, {}), _jsx(ReactQueryDevtools, { initialIsOpen: true })] }) }));
13+
};

examples/react/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { app } from './app';
2+
app();

examples/react/vite.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import react from '@vitejs/plugin-react';
2+
import { defineConfig } from 'vite';
3+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
plugins: [
7+
nodePolyfills(),
8+
react(),
9+
],
10+
});
File renamed without changes.

examples/vanilla/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"private": true,
3+
"type": "module",
4+
"scripts": {
5+
"build": "vite build",
6+
"dev": "vite",
7+
"typecheck": "tsc"
8+
},
9+
"devDependencies": {
10+
"@types/node": "^18.7.23",
11+
"ohmyfetch": "^0.4.20",
12+
"typescript": "^5.0.0",
13+
"vite": "^4.0.0",
14+
"vite-plugin-node-polyfills": "workspace:*"
15+
}
16+
}
File renamed without changes.

examples/vanilla/src/main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Buffer } from 'node:buffer';
2+
import { resolve } from 'node:path';
3+
import * as process from 'node:process';
4+
import fs from 'node:fs';
5+
import { fetch } from 'ohmyfetch';
6+
console.log(fetch);
7+
console.log(resolve('.'));
8+
console.log(process);
9+
console.log(process.env);
10+
console.log(globalThis.Array);
11+
console.log(Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]).readBigUInt64BE(0));
12+
console.log(Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]));
13+
console.log(Array);
14+
console.log(fs);
File renamed without changes.

examples/vanilla/tsconfig.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"module": "ESNext",
4+
"moduleResolution": "Bundler"
5+
}
6+
}

0 commit comments

Comments
 (0)