mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-07 01:02:55 +08:00
2e18f1ebc2
* next 15 * lock * feat: rename .d.ts to .ts for Next 15 compatibility - Rename 104 .d.ts files to .ts (Next 15 no longer supports .d.ts in src) - Remove 5 redundant .d.ts files that had .ts counterparts - Update all import paths: remove .d suffix from 100 import statements - Update tsconfig.json include patterns across all packages - Add pnpm overrides to unify react@18.3.1 across monorepo - Fix react version mismatch (packages/global and packages/service were resolving to react@19.1.1) * fix: resolve 61 TypeScript errors from .d.ts to .ts migration - Fix broken imports using non-relative module paths (e.g. 'support/user/team/type' → relative paths) - Remove unused/dead imports referencing deleted modules - Fix duplicate identifiers (show_emptyChat, concatMd, TrainingModeEnum) - Add missing imports (BoxProps, GroupMemberRole, UsageSourceEnum, dashboard_evaluation) - Fix generic type constraints (OutLinkEditType, createShareChat) - Replace removed types with correct alternatives (ChatModelItemType → LLMModelItemType) - Delete 5 dead code files with 0 references - Add global type declaration for countTrackQueue - Fix nullable type narrowing (sourceMember, ParentIdType, optional app fields) * refactor: replace as ClientSession assertion with proper type narrowing via Omit & intersection * fix: remove experimental.workerThreads to fix DataCloneError in Next 15 static generation Next 15 worker threads attempt to structuredClone the config object, which fails on the webpack function. workerThreads is not needed for the build to work correctly. * Update document/content/docs/upgrading/4-14/4148.mdx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: ts * update next config * update next * fix: dockerfile * fix: comment --------- Co-authored-by: Archer <c121914yu@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
136 lines
3.2 KiB
TypeScript
136 lines
3.2 KiB
TypeScript
import type { NextConfig } from 'next';
|
|
import path from 'path';
|
|
import withBundleAnalyzerInit from '@next/bundle-analyzer';
|
|
|
|
const withBundleAnalyzer = withBundleAnalyzerInit({
|
|
enabled: process.env.ANALYZE === 'true'
|
|
});
|
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
const nextConfig: NextConfig = {
|
|
basePath: process.env.NEXT_PUBLIC_BASE_URL,
|
|
i18n: {
|
|
defaultLocale: 'en',
|
|
locales: ['en', 'zh-CN', 'zh-Hant'],
|
|
localeDetection: false
|
|
},
|
|
output: 'standalone',
|
|
// 开发环境关闭 strict mode,避免第三方库的双重渲染问题
|
|
reactStrictMode: !isDev,
|
|
productionBrowserSourceMaps: false,
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: '/((?!chat/share$).*)',
|
|
headers: [
|
|
{
|
|
key: 'X-Frame-Options',
|
|
value: 'DENY'
|
|
},
|
|
{
|
|
key: 'X-Content-Type-Options',
|
|
value: 'nosniff'
|
|
},
|
|
{
|
|
key: 'X-XSS-Protection',
|
|
value: '1; mode=block'
|
|
},
|
|
{
|
|
key: 'Referrer-Policy',
|
|
value: 'strict-origin-when-cross-origin'
|
|
},
|
|
{
|
|
key: 'Permissions-Policy',
|
|
value: 'geolocation=(self), microphone=(self), camera=(self)'
|
|
}
|
|
]
|
|
}
|
|
];
|
|
},
|
|
|
|
webpack(config, { isServer }) {
|
|
config.ignoreWarnings = [
|
|
...(config.ignoreWarnings || []),
|
|
{
|
|
module: /@scalar\/api-reference-react/,
|
|
message: /autoprefixer/
|
|
}
|
|
];
|
|
|
|
Object.assign(config.resolve!.alias, {
|
|
'@mongodb-js/zstd': false,
|
|
'@aws-sdk/credential-providers': false,
|
|
snappy: false,
|
|
aws4: false,
|
|
'mongodb-client-encryption': false,
|
|
kerberos: false,
|
|
'supports-color': false,
|
|
'bson-ext': false,
|
|
'pg-native': false
|
|
});
|
|
|
|
config.module = {
|
|
...config.module,
|
|
rules: (config.module?.rules || []).concat([
|
|
{
|
|
test: /\.svg$/i,
|
|
issuer: /\.[jt]sx?$/,
|
|
use: ['@svgr/webpack']
|
|
}
|
|
]),
|
|
exprContextCritical: false,
|
|
unknownContextCritical: false
|
|
};
|
|
|
|
if (!config.externals) {
|
|
config.externals = [];
|
|
}
|
|
|
|
if (isServer) {
|
|
(config.externals as string[]).push('@node-rs/jieba');
|
|
}
|
|
|
|
config.experiments = {
|
|
asyncWebAssembly: true,
|
|
layers: true
|
|
};
|
|
|
|
if (isDev && !isServer) {
|
|
config.watchOptions = {
|
|
...config.watchOptions,
|
|
ignored: ['**/node_modules', '**/.git', '**/dist', '**/coverage']
|
|
};
|
|
}
|
|
|
|
return config;
|
|
},
|
|
transpilePackages: ['@modelcontextprotocol/sdk', 'ahooks'],
|
|
serverExternalPackages: [
|
|
'mongoose',
|
|
'pg',
|
|
'bullmq',
|
|
'@zilliz/milvus2-sdk-node',
|
|
'tiktoken',
|
|
'@opentelemetry/api-logs'
|
|
],
|
|
// 优化大库的 barrel exports tree-shaking
|
|
experimental: {
|
|
optimizePackageImports: [
|
|
'@chakra-ui/react',
|
|
'@chakra-ui/icons',
|
|
'lodash',
|
|
'date-fns',
|
|
'ahooks',
|
|
'framer-motion',
|
|
'@emotion/react',
|
|
'@emotion/styled'
|
|
],
|
|
// 按页面拆分 CSS chunk,减少首屏 CSS 体积
|
|
cssChunking: 'strict'
|
|
},
|
|
outputFileTracingRoot: path.join(__dirname, '../../')
|
|
};
|
|
|
|
export default withBundleAnalyzer(nextConfig);
|