Skip to content

Commit d51890f

Browse files
committed
fix: resolve TypeScript type generation and import issues
Fixed two critical bugs preventing frontend build: 1. **TypeScript Type Generation (CommonJS/ESM)** - TypeGen generates CommonJS by default but Vite requires ESM - Created scripts/generate-types.sh to automate proper generation - Script modifies tsconfig.json to output ESM and recompiles TypeScript 2. **useCore.ts Import** - Fixed import to use Model instead of ViewModel - ViewModel was removed in previous refactoring (commit 3957347) These fixes resolve the frontend build error where Rollup couldn't import CommonJS modules from TypeScript files. Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
1 parent 8e82e91 commit d51890f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

scripts/generate-types.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Generate TypeScript types from Rust and convert to ESM
3+
#
4+
# TypeGen outputs CommonJS by default, but Vite requires ESM.
5+
# This script regenerates the types and recompiles them as ESM modules.
6+
7+
set -e
8+
9+
echo "Generating TypeScript types from Rust..."
10+
cargo build -p shared_types
11+
12+
echo "Converting TypeScript compilation to ESM..."
13+
cd src/shared_types/generated/typescript
14+
15+
# Update tsconfig to output ES modules instead of CommonJS
16+
sed -i 's/"module": "commonjs"/"module": "esnext"/' tsconfig.json
17+
18+
# Recompile TypeScript to JavaScript with ES module syntax
19+
export PATH="$HOME/.local/share/pnpm:$PATH"
20+
pnpm exec tsc
21+
22+
echo "TypeScript types generated and converted to ESM successfully!"

src/ui/src/composables/useCore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type {
3333
HealthcheckInfo,
3434
Event,
3535
Effect,
36-
ViewModel as CoreViewModel,
36+
Model as CoreViewModel,
3737
} from '../../../shared_types/generated/typescript/types/shared_types'
3838

3939
// Import event constructors for sending events to the core

0 commit comments

Comments
 (0)