mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
style: 完成所有文件的lint
This commit is contained in:
111
vite.config.ts
111
vite.config.ts
@@ -1,43 +1,40 @@
|
||||
import { defineConfig, type Plugin } from "vite";
|
||||
import { resolve, dirname } from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { readFileSync } from "fs";
|
||||
import { getMacroDefines } from "./scripts/defines";
|
||||
import featureFlagsPlugin from "./scripts/vite-plugin-feature-flags";
|
||||
import importMetaRequirePlugin from "./scripts/vite-plugin-import-meta-require";
|
||||
import { defineConfig, type Plugin } from 'vite'
|
||||
import { resolve, dirname } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { readFileSync } from 'fs'
|
||||
import { getMacroDefines } from './scripts/defines'
|
||||
import featureFlagsPlugin from './scripts/vite-plugin-feature-flags'
|
||||
import importMetaRequirePlugin from './scripts/vite-plugin-import-meta-require'
|
||||
|
||||
const projectRoot = dirname(fileURLToPath(import.meta.url));
|
||||
const projectRoot = dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const acknowledgedBuildWarnings = [
|
||||
"src/utils/sandbox/sandbox-adapter.ts",
|
||||
"packages/builtin-tools/src/tools/ToolSearchTool/prompt.ts",
|
||||
"src/utils/claudemd.ts",
|
||||
"src/services/SessionMemory/sessionMemoryUtils.ts",
|
||||
"src/commands/logout/logout.tsx",
|
||||
"src/utils/sessionStorage.ts",
|
||||
"src/utils/swarm/backends/registry.ts",
|
||||
"src/utils/toolSearch.ts",
|
||||
"src/utils/hooks.ts",
|
||||
"src/services/skillLearning/sessionObserver.ts",
|
||||
"src/utils/settings/changeDetector.ts",
|
||||
];
|
||||
'src/utils/sandbox/sandbox-adapter.ts',
|
||||
'packages/builtin-tools/src/tools/ToolSearchTool/prompt.ts',
|
||||
'src/utils/claudemd.ts',
|
||||
'src/services/SessionMemory/sessionMemoryUtils.ts',
|
||||
'src/commands/logout/logout.tsx',
|
||||
'src/utils/sessionStorage.ts',
|
||||
'src/utils/swarm/backends/registry.ts',
|
||||
'src/utils/toolSearch.ts',
|
||||
'src/utils/hooks.ts',
|
||||
'src/services/skillLearning/sessionObserver.ts',
|
||||
'src/utils/settings/changeDetector.ts',
|
||||
]
|
||||
|
||||
function isAcknowledgedBuildWarning(warning: {
|
||||
code?: string;
|
||||
id?: string;
|
||||
message?: string;
|
||||
code?: string
|
||||
id?: string
|
||||
message?: string
|
||||
}): boolean {
|
||||
if (
|
||||
warning.code === "EVAL" &&
|
||||
warning.id?.includes("@protobufjs+inquire")
|
||||
) {
|
||||
return true;
|
||||
if (warning.code === 'EVAL' && warning.id?.includes('@protobufjs+inquire')) {
|
||||
return true
|
||||
}
|
||||
|
||||
return (
|
||||
warning.code === "INEFFECTIVE_DYNAMIC_IMPORT" &&
|
||||
acknowledgedBuildWarnings.some((id) => warning.message?.includes(id))
|
||||
);
|
||||
warning.code === 'INEFFECTIVE_DYNAMIC_IMPORT' &&
|
||||
acknowledgedBuildWarnings.some(id => warning.message?.includes(id))
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,40 +42,40 @@ function isAcknowledgedBuildWarning(warning: {
|
||||
*/
|
||||
function rawAssetPlugin(extensions: string[]): Plugin {
|
||||
return {
|
||||
name: "raw-asset",
|
||||
enforce: "pre",
|
||||
name: 'raw-asset',
|
||||
enforce: 'pre',
|
||||
resolveId(id, importer) {
|
||||
if (extensions.some((ext) => id.endsWith(ext))) {
|
||||
if (extensions.some(ext => id.endsWith(ext))) {
|
||||
// Resolve to actual file path
|
||||
return this.resolve(id, importer, { skipSelf: true });
|
||||
return this.resolve(id, importer, { skipSelf: true })
|
||||
}
|
||||
return null;
|
||||
return null
|
||||
},
|
||||
load(id) {
|
||||
if (extensions.some((ext) => id.endsWith(ext))) {
|
||||
const content = readFileSync(id, "utf-8");
|
||||
return `export default ${JSON.stringify(content)}`;
|
||||
if (extensions.some(ext => id.endsWith(ext))) {
|
||||
const content = readFileSync(id, 'utf-8')
|
||||
return `export default ${JSON.stringify(content)}`
|
||||
}
|
||||
return null;
|
||||
return null
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
// CLI tool — no browser features needed
|
||||
appType: "custom",
|
||||
appType: 'custom',
|
||||
|
||||
// Tell Vite this is a Node.js build, not browser.
|
||||
// Prevents externalization of Node.js builtins (fs, path, etc.)
|
||||
ssr: {
|
||||
target: "node",
|
||||
target: 'node',
|
||||
noExternal: true,
|
||||
},
|
||||
|
||||
build: {
|
||||
emptyOutDir: true,
|
||||
outDir: "dist",
|
||||
target: "es2020",
|
||||
outDir: 'dist',
|
||||
target: 'es2020',
|
||||
copyPublicDir: false,
|
||||
sourcemap: false,
|
||||
minify: false,
|
||||
@@ -87,24 +84,24 @@ export default defineConfig({
|
||||
ssr: true,
|
||||
|
||||
rollupOptions: {
|
||||
input: resolve(projectRoot, "src/entrypoints/cli.tsx"),
|
||||
input: resolve(projectRoot, 'src/entrypoints/cli.tsx'),
|
||||
|
||||
output: {
|
||||
format: "es",
|
||||
dir: "dist",
|
||||
entryFileNames: "cli.js",
|
||||
chunkFileNames: "chunks/[name]-[hash].js",
|
||||
format: 'es',
|
||||
dir: 'dist',
|
||||
entryFileNames: 'cli.js',
|
||||
chunkFileNames: 'chunks/[name]-[hash].js',
|
||||
},
|
||||
|
||||
plugins: [
|
||||
rawAssetPlugin([".md", ".txt", ".html", ".css"]),
|
||||
rawAssetPlugin(['.md', '.txt', '.html', '.css']),
|
||||
featureFlagsPlugin(),
|
||||
importMetaRequirePlugin(),
|
||||
],
|
||||
|
||||
onwarn(warning, defaultHandler) {
|
||||
if (isAcknowledgedBuildWarning(warning)) return;
|
||||
defaultHandler(warning);
|
||||
if (isAcknowledgedBuildWarning(warning)) return
|
||||
defaultHandler(warning)
|
||||
},
|
||||
},
|
||||
|
||||
@@ -119,11 +116,11 @@ export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
// src/* path alias (mirrors tsconfig paths)
|
||||
"src/": resolve(projectRoot, "src/"),
|
||||
'src/': resolve(projectRoot, 'src/'),
|
||||
},
|
||||
// Ensure workspace packages share a single copy of these
|
||||
dedupe: ["react", "react-reconciler", "react-compiler-runtime"],
|
||||
dedupe: ['react', 'react-reconciler', 'react-compiler-runtime'],
|
||||
// Resolve .js imports to .ts files (Bun does this automatically)
|
||||
extensions: [".ts", ".tsx", ".js", ".jsx", ".json"],
|
||||
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user