From 97bf0733b96e242011f402f8874ef2f2a3feddc8 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 05:15:37 +0000 Subject: [PATCH 1/2] build: fix pre-commit TypeScript type checking The pre-commit hook previously ran `yarn tsc` which does nothing meaningful because the root tsconfig.json has `"files": []` with only project references. This meant TypeScript errors weren't being caught locally but would fail in CI. Changes: - Use `yarn tsc --build` to properly build all project references - When WASM modules aren't built, check independent projects (core, website, engine2, xmutil-js) that don't depend on WASM - Fix rspress.config.ts type error by migrating from deprecated `analytics` config to `builderPlugins` with rsbuild-plugin-google- analytics The rspress 1.44.0 no longer supports the `analytics` top-level config property. Google Analytics must now be configured via the rsbuild-plugin-google-analytics plugin through the builderPlugins config. --- scripts/pre-commit | 76 +++++++++++++++++++++++++++++++++------ website/package.json | 1 + website/rspress.config.ts | 13 +++---- yarn.lock | 5 +++ 4 files changed, 79 insertions(+), 16 deletions(-) diff --git a/scripts/pre-commit b/scripts/pre-commit index a1cbe6bc..8a86ee39 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -77,18 +77,74 @@ else exit 1 fi - echo -n "Checking TypeScript types... " - TSC_OUTPUT="$(mktemp)" - if yarn tsc > "$TSC_OUTPUT" 2>&1; then - echo -e "${GREEN}✓${NC}" - rm -f "$TSC_OUTPUT" + # Check if WASM modules are built (required for full type checking) + ENGINE_WASM="$REPO_ROOT/src/engine/core" + IMPORTER_WASM="$REPO_ROOT/src/importer/core" + + if [ -d "$ENGINE_WASM" ] && [ -d "$IMPORTER_WASM" ]; then + # Full WASM build available - check all projects + echo -n "Checking TypeScript types (full)... " + TSC_OUTPUT="$(mktemp)" + if yarn tsc --build > "$TSC_OUTPUT" 2>&1; then + echo -e "${GREEN}✓${NC}" + rm -f "$TSC_OUTPUT" + else + echo -e "${RED}✗${NC}" + echo -e "${RED}TypeScript type checking failed:${NC}" + cat "$TSC_OUTPUT" + rm -f "$TSC_OUTPUT" + echo -e "${YELLOW}Run 'yarn tsc --build' to see errors${NC}" + exit 1 + fi else - echo -e "${RED}✗${NC}" - echo -e "${RED}TypeScript type checking failed:${NC}" - cat "$TSC_OUTPUT" + # WASM not built - check projects that don't depend on WASM + echo -e "${YELLOW}WASM not built - checking independent projects only${NC}" + TSC_OUTPUT="$(mktemp)" + TSC_FAILED=0 + + echo -n " Checking core... " + if yarn tsc --build src/core > "$TSC_OUTPUT" 2>&1; then + echo -e "${GREEN}✓${NC}" + else + echo -e "${RED}✗${NC}" + cat "$TSC_OUTPUT" + TSC_FAILED=1 + fi + + echo -n " Checking website... " + if yarn tsc --build website > "$TSC_OUTPUT" 2>&1; then + echo -e "${GREEN}✓${NC}" + else + echo -e "${RED}✗${NC}" + cat "$TSC_OUTPUT" + TSC_FAILED=1 + fi + + echo -n " Checking engine2... " + if yarn tsc --build src/engine2 > "$TSC_OUTPUT" 2>&1; then + echo -e "${GREEN}✓${NC}" + else + echo -e "${RED}✗${NC}" + cat "$TSC_OUTPUT" + TSC_FAILED=1 + fi + + echo -n " Checking xmutil-js... " + if yarn tsc --build src/xmutil-js > "$TSC_OUTPUT" 2>&1; then + echo -e "${GREEN}✓${NC}" + else + echo -e "${RED}✗${NC}" + cat "$TSC_OUTPUT" + TSC_FAILED=1 + fi + rm -f "$TSC_OUTPUT" - echo -e "${YELLOW}Run 'yarn tsc' to see errors${NC}" - exit 1 + + if [ "$TSC_FAILED" -eq 1 ]; then + echo -e "${RED}TypeScript type checking failed${NC}" + echo -e "${YELLOW}Run 'yarn tsc --build' to see all errors${NC}" + exit 1 + fi fi # Run engine2 tests if WASM is built diff --git a/website/package.json b/website/package.json index 86a4f328..0fc2e6d8 100644 --- a/website/package.json +++ b/website/package.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@emotion/react": "^11.14.0", + "rsbuild-plugin-google-analytics": "^1.0.2", "@emotion/styled": "^11.14.0", "@mui/material": "^7.1.2", "@types/react": "^19.0.0", diff --git a/website/rspress.config.ts b/website/rspress.config.ts index 5757d8ce..75c20363 100644 --- a/website/rspress.config.ts +++ b/website/rspress.config.ts @@ -1,5 +1,6 @@ import { defineConfig } from 'rspress/config'; import path from 'path'; +import { pluginGoogleAnalytics } from 'rsbuild-plugin-google-analytics'; const GithubBase = 'https://github.com/bpowers/simlin'; @@ -104,12 +105,12 @@ export default defineConfig({ }, // Output configuration outDir: 'build', - // Analytics - analytics: { - ga: { - measurementId: 'G-DYC89XS4YM', - }, - }, + // Builder plugins (includes Google Analytics) + builderPlugins: [ + pluginGoogleAnalytics({ + id: 'G-DYC89XS4YM', + }), + ], // Generate sitemap ssg: true, }); diff --git a/yarn.lock b/yarn.lock index 609b4655..edee454f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12212,6 +12212,11 @@ router@^2.0.0, router@^2.2.0: parseurl "^1.3.3" path-to-regexp "^8.0.0" +rsbuild-plugin-google-analytics@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/rsbuild-plugin-google-analytics/-/rsbuild-plugin-google-analytics-1.0.5.tgz#dfd0e97a34fe467a3a9394f9b1d6b507045d6a84" + integrity sha512-1qSMjmH3HBNMIyrRjBFHQKmTdL86VNc42HjL3z25z4k4n+N7+cl9UvpD5ou3G6YAn1jNJ2GS2pia+PKNyaTzmg== + rspack-plugin-virtual-module@0.1.13: version "0.1.13" resolved "https://registry.yarnpkg.com/rspack-plugin-virtual-module/-/rspack-plugin-virtual-module-0.1.13.tgz#2acb3e5bba6fff458fd3428322978e0a51bb3294" From fd72aef7e804862541c407473b7cf6e7b8cb8f63 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 05:16:43 +0000 Subject: [PATCH 2/2] build: ignore TypeScript build artifacts Add gitignore patterns for files generated by `yarn tsc --build`: - *.tsbuildinfo files - Generated .js, .js.map, .d.ts in src/engine/ and src/importer/ - Generated .js files in website/ These artifacts are created when running type checking with the --build flag and should not be committed. --- .gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index a302f159..5c3a7154 100644 --- a/.gitignore +++ b/.gitignore @@ -90,3 +90,14 @@ __pycache__/ .hypothesis/ .ai-tool-config + +# TypeScript build artifacts (generated by tsc --build) +*.tsbuildinfo +/src/engine/*.js +/src/engine/*.js.map +/src/engine/*.d.ts +/src/importer/*.js +/src/importer/*.js.map +/src/importer/*.d.ts +/website/rspress.config.js +/website/docs/**/*.js