From 08d1f6bf672181b0c3eb0757d7709122b2e37157 Mon Sep 17 00:00:00 2001 From: tecvan <84165678+Tecvan-fe@users.noreply.github.com> Date: Mon, 4 Aug 2025 10:24:00 +0800 Subject: [PATCH] chore: impprove ts server perf of vscode (#511) --- .../agents/frontend-infrastructure-expert.md | 31 +++++++++++++++++++ .vscode/settings.template.json | 26 ++++++++++++---- frontend/config/ts-config/tsconfig.base.json | 24 ++++++++------ 3 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 .claude/agents/frontend-infrastructure-expert.md diff --git a/.claude/agents/frontend-infrastructure-expert.md b/.claude/agents/frontend-infrastructure-expert.md new file mode 100644 index 00000000..26fd3e11 --- /dev/null +++ b/.claude/agents/frontend-infrastructure-expert.md @@ -0,0 +1,31 @@ +--- +name: frontend-infrastructure-expert +description: Use this agent when you need help with frontend build tools, configuration files, or infrastructure-related issues. Examples include: configuring rspack bundler settings, setting up or modifying ESLint rules and configurations, working with rush.json for monorepo management, troubleshooting build pipeline issues, optimizing webpack or rspack performance, setting up development environment configurations, resolving dependency conflicts in package.json files, configuring TypeScript compiler options for build tools, setting up CI/CD pipelines for frontend projects, or debugging issues with bundlers, linters, or other frontend tooling. +model: sonnet +color: cyan +--- + +You are a Frontend Infrastructure Expert, a specialist in modern frontend build systems, tooling, and development environment configuration. Your expertise spans bundlers (rspack, webpack, vite), linters (ESLint, Prettier), monorepo tools (Rush, Lerna, Nx), package managers, and CI/CD pipelines for frontend applications. + +Your core responsibilities: +- Configure and optimize build tools like rspack, webpack, and other bundlers for performance and developer experience +- Set up and maintain ESLint configurations, including custom rules, plugins, and integration with IDEs +- Manage rush.json and other monorepo configuration files for scalable project organization +- Troubleshoot infrastructure-related issues including build failures, dependency conflicts, and tooling errors +- Optimize development workflows through proper tooling configuration +- Ensure consistent code quality through automated tooling setup + +When working on configurations: +1. Always consider the project's existing structure and dependencies before making changes +2. Prioritize developer experience and build performance equally +3. Ensure configurations are maintainable and well-documented through inline comments +4. Test configurations thoroughly and provide clear instructions for verification +5. Consider cross-platform compatibility (Windows, macOS, Linux) + +For troubleshooting: +1. Systematically diagnose issues by checking logs, configurations, and dependencies +2. Provide step-by-step solutions with clear explanations +3. Suggest preventive measures to avoid similar issues +4. Recommend best practices for long-term maintainability + +Always explain your reasoning behind configuration choices and provide alternative approaches when applicable. Focus on solutions that scale with team growth and project complexity. diff --git a/.vscode/settings.template.json b/.vscode/settings.template.json index 52796128..d8490342 100644 --- a/.vscode/settings.template.json +++ b/.vscode/settings.template.json @@ -102,23 +102,37 @@ "typescript.referencesCodeLens.enabled": false, "typescript.preferGoToSourceDefinition": true, "typescript.updateImportsOnFileMove.enabled": "never", - // tsserver logs are not automatically deleted and accumulate over time, causing disk space issues, so disabled by default + // tsserver log 不会自动删除,日积月累,导致磁盘空间不足,因此默认关闭 "typescript.tsserver.log": "off", - "typescript.tsserver.experimental.enableProjectDiagnostics": false, + // "typescript.tsserver.useSeparateSyntaxServer": true, + "typescript.tsserver.forceConsistentCasingInFileNames": true, "typescript.workspaceSymbols.excludeLibrarySymbols": true, "editor.minimap.enabled": true, "typescript.preferences.includePackageJsonAutoImports": "off", "typescript.suggest.autoImports": true, - "typescript.tsserver.maxTsServerMemory": 10240, + "typescript.tsserver.maxTsServerMemory": 16384, "typescript.tsserver.enableRegionDiagnostics": false, + "typescript.tsserver.experimental.enableProjectDiagnostics": true, "typescript.tsserver.watchOptions": { "fallbackPolling": "dynamicPriorityPolling", - "synchronousWatchDirectory": true, + "synchronousWatchDirectory": false, "watchDirectory": "useFsEvents", "watchFile": "useFsEventsOnParentDirectory", - "excludeDirectories": ["/**/node_modules"], + "excludeDirectories": [ + "/**/node_modules", + "/**/dist", + "/**/lib", + "/**/coverage", + "**/temp" + ], "excludeLibrarySymbols": true, - "excludeFiles": ["/**/node_modules/**"] + "excludeFiles": [ + "/**/node_modules/**", + "/**/dist/**", + "/**/lib/**", + "/**/coverage/**", + "**/temp/**" + ] }, "css.validate": false, "scss.validate": false, diff --git a/frontend/config/ts-config/tsconfig.base.json b/frontend/config/ts-config/tsconfig.base.json index e44af0ea..3cc7ceae 100644 --- a/frontend/config/ts-config/tsconfig.base.json +++ b/frontend/config/ts-config/tsconfig.base.json @@ -24,26 +24,32 @@ "sourceMap": true, "strict": true, "disableReferencedProjectLoad": true, - // "disableSolutionSearching": true, - // "disableSourceOfProjectReferenceRedirect": true, + "disableSolutionSearching": true, + "disableSourceOfProjectReferenceRedirect": true, "target": "es2018" }, "watchOptions": { - "fallbackPolling": "dynamicpriority", + "fallbackPolling": "dynamicPriorityPolling", "synchronousWatchDirectory": false, - "watchDirectory": "fixedChunkSizePolling", + "watchDirectory": "useFsEvents", "watchFile": "useFsEventsOnParentDirectory", "excludeDirectories": [ "../../**/__tests__/", "../../**/__coverage__/", "../../**/__mocks__/", - "/**/node_modules/**" + "/**/node_modules/**", + "/**/dist/**", + "/**/lib/**", + "**/temp/**" ], "excludeFiles": [ - "../../**/__tests__", - "../../**/__coverage__", - "../../**/__mocks__", - "/**/node_modules/**" + "../../**/__tests__/**", + "../../**/__coverage__/**", + "../../**/__mocks__/**", + "/**/node_modules/**", + "/**/dist/**", + "/**/lib/**", + "**/temp/**" ] } }