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 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"