@miden-sdk/create-miden-para-react 0.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/bin/create-miden-para-react.mjs +296 -0
- package/package.json +42 -0
- package/template/src/App.tsx +46 -0
- package/template/src/optional-connectors.ts +1 -0
- package/template/src/polyfills.ts +11 -0
- package/template/vite.config.ts +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @miden-sdk/create-miden-para-react
|
|
2
|
+
|
|
3
|
+
`npm create @miden-sdk/miden-para-react@latest my-app` scaffolds the latest Vite `react-ts` starter, overwrites it with this repo's `vite.config.ts`, swaps in a Para + Miden-ready `App.tsx`, and adds the deps needed to run it out of the box. The scaffold always runs `create-vite` with `--yes --no-install` and pipes “no” to the install prompt to prevent upstream installs from overwriting the template before we patch it.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
- Runs `npm create vite@latest <target> -- --template react-ts` so you always start from the upstream default.
|
|
7
|
+
- Replaces `vite.config.ts` with the Para + Miden-friendly config (dedupe/exclude and WASM asset handling).
|
|
8
|
+
- Replaces `src/App.tsx` with a ParaProvider + `useParaMiden` starter that reports the account ID and client readiness.
|
|
9
|
+
- Adds Para/Miden + connector deps (matching `examples/react`) so Para SDK peers resolve: `@miden-sdk/miden-para`, `@miden-sdk/use-miden-para-react`, `@getpara/react-sdk-lite`, `@getpara/evm-wallet-connectors`, `@demox-labs/miden-sdk`, `@tanstack/react-query`, `@wagmi/core`, `viem`, `wagmi`, plus dev plugins `vite-plugin-node-polyfills`, `vite-plugin-wasm`, and `vite-plugin-top-level-await`.
|
|
10
|
+
- Installs dependencies using your detected package manager (`pnpm`, `yarn`, `bun`, or falls back to `npm`); `create-vite` is invoked with `--yes --no-install` and auto-answers “no” to install prompts to avoid reverting the patched files.
|
|
11
|
+
- Writes `.npmrc` with `legacy-peer-deps=true` so `npm install` works despite a known peer mismatch between `@miden-sdk/use-miden-para-react` and `@miden-sdk/miden-para`.
|
|
12
|
+
- Adds `src/polyfills.ts` and injects it into `src/main.tsx` to provide `Buffer`/`process` in the browser.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
- Standard: `npm create @miden-sdk/miden-para-react@latest my-new-app`
|
|
16
|
+
- Skip install: add `--skip-install` if you want to install later.
|
|
17
|
+
- Set `VITE_PARA_API_KEY` in a `.env.local` (or similar) file so the generated `App.tsx` can initialize Para. **Production deployments require a Para production API key.**
|
|
18
|
+
- Recommended next steps: `cd my-new-app && npm install && npm run dev` (`.npmrc` opts into legacy peer deps so npm works).
|
|
19
|
+
|
|
20
|
+
Publish from this folder with `npm publish --access public` when you're ready. For local testing, run `node ./packages/create-miden-para-react/bin/create-miden-para-react.mjs my-app`.
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
copyFileSync,
|
|
6
|
+
existsSync,
|
|
7
|
+
mkdirSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
writeFileSync,
|
|
10
|
+
} from "node:fs";
|
|
11
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
const templateConfigPath = resolve(__dirname, "..", "template", "vite.config.ts");
|
|
17
|
+
const templateAppPath = resolve(__dirname, "..", "template", "src", "App.tsx");
|
|
18
|
+
const templatePolyfillsPath = resolve(__dirname, "..", "template", "src", "polyfills.ts");
|
|
19
|
+
const templateOptionalConnectorsPath = resolve(
|
|
20
|
+
__dirname,
|
|
21
|
+
"..",
|
|
22
|
+
"template",
|
|
23
|
+
"src",
|
|
24
|
+
"optional-connectors.ts"
|
|
25
|
+
);
|
|
26
|
+
const repoRoot = resolve(__dirname, "..", "..", "..");
|
|
27
|
+
const localMidenParaPath =
|
|
28
|
+
process.env.MIDEN_PARA_LOCAL_MIDEN_PARA_PATH ?? repoRoot;
|
|
29
|
+
const localUseMidenParaReactPath =
|
|
30
|
+
process.env.MIDEN_PARA_LOCAL_USE_PARA_REACT_PATH ??
|
|
31
|
+
resolve(repoRoot, "packages", "use-miden-para-react");
|
|
32
|
+
const useLocalDeps = process.env.MIDEN_PARA_LOCAL_DEPS === "1";
|
|
33
|
+
|
|
34
|
+
const args = process.argv.slice(2);
|
|
35
|
+
const target = args.find((arg) => !arg.startsWith("-")) ?? "miden-para-react-app";
|
|
36
|
+
const skipInstall = args.some(
|
|
37
|
+
(flag) => flag === "--skip-install" || flag === "--no-install",
|
|
38
|
+
);
|
|
39
|
+
const skipScaffold =
|
|
40
|
+
args.some((flag) => flag === "--skip-scaffold" || flag === "--no-scaffold") ||
|
|
41
|
+
process.env.MIDEN_PARA_TEST_MODE === "1";
|
|
42
|
+
const targetDir = resolve(process.cwd(), target);
|
|
43
|
+
const targetParent = dirname(targetDir);
|
|
44
|
+
const targetName = basename(targetDir);
|
|
45
|
+
const baseEnv = {
|
|
46
|
+
...process.env,
|
|
47
|
+
CI: process.env.CI ?? "true",
|
|
48
|
+
npm_config_yes: process.env.npm_config_yes ?? "true",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
ensureTargetParent();
|
|
52
|
+
if (skipScaffold) {
|
|
53
|
+
scaffoldMinimalProject(targetDir, targetName);
|
|
54
|
+
} else {
|
|
55
|
+
runCreateVite(targetName);
|
|
56
|
+
}
|
|
57
|
+
overrideViteConfig(targetDir);
|
|
58
|
+
overrideApp(targetDir);
|
|
59
|
+
ensurePolyfills(targetDir);
|
|
60
|
+
ensureOptionalConnectorsShim(targetDir);
|
|
61
|
+
ensurePolyfillDependency(targetDir);
|
|
62
|
+
ensureMidenParaDependencies(targetDir);
|
|
63
|
+
ensureNpmRc(targetDir);
|
|
64
|
+
logEnvReminder(targetName);
|
|
65
|
+
|
|
66
|
+
if (!skipInstall) {
|
|
67
|
+
installDependencies(targetDir);
|
|
68
|
+
} else {
|
|
69
|
+
logStep("Skipped dependency installation (--skip-install)");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function ensureTargetParent() {
|
|
73
|
+
mkdirSync(targetParent, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function runCreateVite(targetArg) {
|
|
77
|
+
const scaffoldArgs = [
|
|
78
|
+
"create",
|
|
79
|
+
"vite@latest",
|
|
80
|
+
targetArg,
|
|
81
|
+
"--",
|
|
82
|
+
"--template",
|
|
83
|
+
"react-ts",
|
|
84
|
+
"--yes", // avoid interactive prompts that might install/revert files
|
|
85
|
+
"--no-install", // we handle installs after patching package.json
|
|
86
|
+
];
|
|
87
|
+
runOrExit("npm", scaffoldArgs, targetParent, baseEnv, "n\n");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function scaffoldMinimalProject(targetRoot, name) {
|
|
91
|
+
mkdirSync(targetRoot, { recursive: true });
|
|
92
|
+
const pkgPath = join(targetRoot, "package.json");
|
|
93
|
+
if (!existsSync(pkgPath)) {
|
|
94
|
+
const pkg = {
|
|
95
|
+
name,
|
|
96
|
+
private: true,
|
|
97
|
+
version: "0.0.0",
|
|
98
|
+
type: "module",
|
|
99
|
+
scripts: {
|
|
100
|
+
dev: "vite",
|
|
101
|
+
build: "vite build",
|
|
102
|
+
preview: "vite preview",
|
|
103
|
+
},
|
|
104
|
+
dependencies: {
|
|
105
|
+
react: "^18.2.0",
|
|
106
|
+
"react-dom": "^18.2.0",
|
|
107
|
+
},
|
|
108
|
+
devDependencies: {
|
|
109
|
+
"@types/react": "^18.2.0",
|
|
110
|
+
"@types/react-dom": "^18.2.0",
|
|
111
|
+
"@vitejs/plugin-react": "^4.2.0",
|
|
112
|
+
typescript: "^5.2.2",
|
|
113
|
+
vite: "^5.2.0",
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const srcDir = join(targetRoot, "src");
|
|
120
|
+
mkdirSync(srcDir, { recursive: true });
|
|
121
|
+
const mainPath = join(srcDir, "main.tsx");
|
|
122
|
+
if (!existsSync(mainPath)) {
|
|
123
|
+
writeFileSync(
|
|
124
|
+
mainPath,
|
|
125
|
+
`import React from "react";\nimport ReactDOM from "react-dom/client";\nimport App from "./App";\n\nReactDOM.createRoot(document.getElementById("root")!).render(<App />);\n`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const appPath = join(srcDir, "App.tsx");
|
|
129
|
+
if (!existsSync(appPath)) {
|
|
130
|
+
writeFileSync(appPath, "export default function App() { return null; }\n");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function overrideViteConfig(targetRoot) {
|
|
135
|
+
const dest = join(targetRoot, "vite.config.ts");
|
|
136
|
+
copyFileSync(templateConfigPath, dest);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function overrideApp(targetRoot) {
|
|
140
|
+
const dest = join(targetRoot, "src", "App.tsx");
|
|
141
|
+
mkdirSync(join(targetRoot, "src"), { recursive: true });
|
|
142
|
+
logStep(`Replacing App.tsx with Para + Miden starter at ${dest}`);
|
|
143
|
+
copyFileSync(templateAppPath, dest);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function ensurePolyfills(targetRoot) {
|
|
147
|
+
const dest = join(targetRoot, "src", "polyfills.ts");
|
|
148
|
+
mkdirSync(join(targetRoot, "src"), { recursive: true });
|
|
149
|
+
copyFileSync(templatePolyfillsPath, dest);
|
|
150
|
+
|
|
151
|
+
const mainPath = join(targetRoot, "src", "main.tsx");
|
|
152
|
+
if (existsSync(mainPath)) {
|
|
153
|
+
const main = readFileSync(mainPath, "utf8");
|
|
154
|
+
if (!main.includes('./polyfills') && !main.includes("./polyfills")) {
|
|
155
|
+
writeFileSync(mainPath, `import "./polyfills";\n${main}`);
|
|
156
|
+
logStep(`Injected polyfills import into ${mainPath}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function ensureOptionalConnectorsShim(targetRoot) {
|
|
162
|
+
const dest = join(targetRoot, "src", "optional-connectors.ts");
|
|
163
|
+
mkdirSync(join(targetRoot, "src"), { recursive: true });
|
|
164
|
+
copyFileSync(templateOptionalConnectorsPath, dest);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function ensurePolyfillDependency(targetRoot) {
|
|
168
|
+
const pkgPath = join(targetRoot, "package.json");
|
|
169
|
+
if (!existsSync(pkgPath)) {
|
|
170
|
+
logStep("No package.json found after scaffolding; nothing to patch");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
175
|
+
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
176
|
+
pkg.devDependencies["vite-plugin-node-polyfills"] ??= "^0.24.0";
|
|
177
|
+
pkg.devDependencies["vite-plugin-wasm"] ??= "^3.5.0";
|
|
178
|
+
pkg.devDependencies["vite-plugin-top-level-await"] ??= "^1.6.0";
|
|
179
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
180
|
+
logStep("Added Vite plugin deps (polyfills/wasm/top-level-await)");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function ensureNpmRc(targetRoot) {
|
|
184
|
+
const npmrcPath = join(targetRoot, ".npmrc");
|
|
185
|
+
const line = "legacy-peer-deps=true";
|
|
186
|
+
if (existsSync(npmrcPath)) {
|
|
187
|
+
const contents = readFileSync(npmrcPath, "utf8");
|
|
188
|
+
if (contents.includes(line)) {
|
|
189
|
+
logStep("Existing .npmrc already opts into legacy-peer-deps");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
writeFileSync(npmrcPath, `${contents.trim()}\n${line}\n`);
|
|
193
|
+
logStep("Updated .npmrc to include legacy-peer-deps");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
writeFileSync(npmrcPath, `${line}\n`);
|
|
197
|
+
logStep("Created .npmrc with legacy-peer-deps=true");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function ensureMidenParaDependencies(targetRoot) {
|
|
201
|
+
const pkgPath = join(targetRoot, "package.json");
|
|
202
|
+
if (!existsSync(pkgPath)) {
|
|
203
|
+
logStep("No package.json found after scaffolding; cannot add dependencies");
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
208
|
+
pkg.dependencies = pkg.dependencies ?? {};
|
|
209
|
+
pkg.devDependencies = pkg.devDependencies ?? {};
|
|
210
|
+
pkg.resolutions = pkg.resolutions ?? {};
|
|
211
|
+
pkg.scripts = pkg.scripts ?? {};
|
|
212
|
+
const midenParaVersion = useLocalDeps
|
|
213
|
+
? `file:${localMidenParaPath}`
|
|
214
|
+
: "0.10.10";
|
|
215
|
+
const useMidenParaReactVersion = useLocalDeps
|
|
216
|
+
? `file:${localUseMidenParaReactPath}`
|
|
217
|
+
: "^0.10.10";
|
|
218
|
+
// Align with examples/react so Para SDK connector peers are satisfied
|
|
219
|
+
Object.assign(pkg.dependencies, {
|
|
220
|
+
...pkg.dependencies,
|
|
221
|
+
"@getpara/react-sdk-lite": "2.0.0-alpha.73",
|
|
222
|
+
"@getpara/evm-wallet-connectors": "^2.3.0",
|
|
223
|
+
"@tanstack/react-query": "^5.90.12",
|
|
224
|
+
"@wagmi/core": "^3.0.0",
|
|
225
|
+
"@demox-labs/miden-sdk": "^0.12.5",
|
|
226
|
+
"@miden-sdk/miden-para": midenParaVersion,
|
|
227
|
+
"@miden-sdk/use-miden-para-react": useMidenParaReactVersion,
|
|
228
|
+
viem: "^2.41.2",
|
|
229
|
+
wagmi: "^3.1.0",
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
Object.assign(pkg.devDependencies, {
|
|
233
|
+
...pkg.devDependencies,
|
|
234
|
+
"vite-plugin-node-polyfills": "^0.24.0",
|
|
235
|
+
"vite-plugin-wasm": "^3.5.0",
|
|
236
|
+
"vite-plugin-top-level-await": "^1.6.0",
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
Object.assign(pkg.resolutions, {
|
|
241
|
+
"@getpara/react-sdk": "2.0.0-alpha.73",
|
|
242
|
+
"@getpara/web-sdk": "2.0.0-alpha.73",
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
Object.assign(pkg.scripts, {
|
|
246
|
+
...pkg.scripts,
|
|
247
|
+
'postinstall': 'setup-para'
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
delete pkg.peerDependencies;
|
|
251
|
+
|
|
252
|
+
writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
253
|
+
logStep("Added Para + Miden starter dependencies");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function installDependencies(targetRoot) {
|
|
257
|
+
const pm = detectPackageManager();
|
|
258
|
+
logStep(`Installing dependencies with ${pm.command}`);
|
|
259
|
+
runOrExit(pm.command, pm.args, targetRoot);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function detectPackageManager() {
|
|
263
|
+
const ua = process.env.npm_config_user_agent || "";
|
|
264
|
+
if (ua.startsWith("pnpm")) return { command: "pnpm", args: ["install"] };
|
|
265
|
+
if (ua.startsWith("yarn")) return { command: "yarn", args: [] };
|
|
266
|
+
if (ua.startsWith("bun")) return { command: "bun", args: ["install"] };
|
|
267
|
+
return { command: "npm", args: ["install"] };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function runOrExit(command, args, cwd, env, input) {
|
|
271
|
+
const result = spawnSync(command, args, {
|
|
272
|
+
stdio: input ? ["pipe", "inherit", "inherit"] : "inherit",
|
|
273
|
+
input,
|
|
274
|
+
cwd,
|
|
275
|
+
env,
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
if (result.error) {
|
|
279
|
+
console.error(result.error);
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (result.status !== 0) {
|
|
284
|
+
process.exit(result.status ?? 1);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function logStep(message) {
|
|
289
|
+
console.log(`\n> ${message}`);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function logEnvReminder(dirName) {
|
|
293
|
+
logStep(
|
|
294
|
+
`Remember to use VITE_PARA_API_KEY like this:\n cd ${dirName}\n VITE_PARA_API_KEY=... npm run dev`,
|
|
295
|
+
);
|
|
296
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@miden-sdk/create-miden-para-react",
|
|
3
|
+
"version": "0.10.10",
|
|
4
|
+
"description": "Create a Vite react-ts app preconfigured with Miden + Para's Vite setup",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-miden-para-react": "./bin/create-miden-para-react.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"template",
|
|
12
|
+
"README.md",
|
|
13
|
+
"package.json"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Miden Labs",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/0xMiden/miden-para",
|
|
23
|
+
"directory": "packages/create-miden-para-react"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/0xMiden/miden-para/issues"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"create-vite",
|
|
33
|
+
"vite",
|
|
34
|
+
"react",
|
|
35
|
+
"typescript",
|
|
36
|
+
"miden",
|
|
37
|
+
"para"
|
|
38
|
+
],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"publish": "npm publish"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import './App.css';
|
|
2
|
+
import '@getpara/react-sdk-lite/styles.css';
|
|
3
|
+
import { ParaProvider, useAccount, useModal } from '@getpara/react-sdk-lite';
|
|
4
|
+
import { useParaMiden } from '@miden-sdk/use-miden-para-react';
|
|
5
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
6
|
+
|
|
7
|
+
const queryClient = new QueryClient();
|
|
8
|
+
|
|
9
|
+
function App() {
|
|
10
|
+
return (
|
|
11
|
+
<QueryClientProvider client={queryClient}>
|
|
12
|
+
<ParaProvider
|
|
13
|
+
paraClientConfig={{
|
|
14
|
+
apiKey: import.meta.env.VITE_PARA_API_KEY,
|
|
15
|
+
}}
|
|
16
|
+
config={{ appName: 'Starter for MidenxPara' }}
|
|
17
|
+
>
|
|
18
|
+
<Content />
|
|
19
|
+
</ParaProvider>
|
|
20
|
+
</QueryClientProvider>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function Content() {
|
|
25
|
+
const { client, accountId, para } = useParaMiden(
|
|
26
|
+
'https://rpc.testnet.miden.io'
|
|
27
|
+
);
|
|
28
|
+
const { isConnected } = useAccount();
|
|
29
|
+
const { openModal } = useModal();
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div>
|
|
33
|
+
<button onClick={() => (isConnected ? para?.logout() : openModal?.())}>
|
|
34
|
+
{isConnected ? 'Disconnect Para' : 'Connect with Para'}
|
|
35
|
+
</button>
|
|
36
|
+
{isConnected && (
|
|
37
|
+
<>
|
|
38
|
+
<p>Account: {accountId ?? '—'}</p>
|
|
39
|
+
<p>Client ready: {client ? 'yes' : 'no'}</p>
|
|
40
|
+
</>
|
|
41
|
+
)}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default App;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Buffer } from "buffer";
|
|
2
|
+
import process from "process";
|
|
3
|
+
|
|
4
|
+
// Ensure Node globals exist when dependencies expect them in the browser.
|
|
5
|
+
if (!globalThis.Buffer) {
|
|
6
|
+
globalThis.Buffer = Buffer;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (!globalThis.process) {
|
|
10
|
+
globalThis.process = process;
|
|
11
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { defineConfig } from 'vite';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
4
|
+
import wasm from 'vite-plugin-wasm';
|
|
5
|
+
import topLevelAwait from 'vite-plugin-top-level-await';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { fileURLToPath } from 'url';
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const optionalConnectorsPath = path.resolve(
|
|
11
|
+
__dirname,
|
|
12
|
+
'src',
|
|
13
|
+
'optional-connectors.ts'
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
// Keep the miden SDK unbundled so its WASM asset path stays valid in dev.
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
plugins: [
|
|
19
|
+
wasm(),
|
|
20
|
+
topLevelAwait(),
|
|
21
|
+
react(),
|
|
22
|
+
nodePolyfills({
|
|
23
|
+
include: ['buffer', 'crypto', 'stream', 'util'],
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
optimizeDeps: {
|
|
27
|
+
// Keep Miden SDK unbundled and avoid prebundling Para's Stencil component bundles
|
|
28
|
+
// to prevent multiple runtimes in dev.
|
|
29
|
+
exclude: [
|
|
30
|
+
'@demox-labs/miden-sdk',
|
|
31
|
+
'@getpara/solana-wallet-connectors',
|
|
32
|
+
'@getpara/cosmos-wallet-connectors',
|
|
33
|
+
],
|
|
34
|
+
esbuildOptions: {
|
|
35
|
+
target: 'esnext',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
build: {
|
|
39
|
+
target: 'esnext',
|
|
40
|
+
rollupOptions: {
|
|
41
|
+
external: [
|
|
42
|
+
'@getpara/solana-wallet-connectors',
|
|
43
|
+
'@getpara/cosmos-wallet-connectors',
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
worker: {
|
|
48
|
+
format: 'es',
|
|
49
|
+
},
|
|
50
|
+
resolve: {
|
|
51
|
+
dedupe: ['@getpara/web-sdk', '@getpara/react-sdk-lite'],
|
|
52
|
+
alias: {
|
|
53
|
+
'@getpara/solana-wallet-connectors': optionalConnectorsPath,
|
|
54
|
+
'@getpara/cosmos-wallet-connectors': optionalConnectorsPath,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
// Ensure Vite treats wasm as a static asset with the correct MIME type.
|
|
58
|
+
assetsInclude: ['**/*.wasm'],
|
|
59
|
+
server: {
|
|
60
|
+
fs: {
|
|
61
|
+
allow: [process.cwd()],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|