mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-05 01:02:59 +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>
134 lines
3.2 KiB
JavaScript
134 lines
3.2 KiB
JavaScript
const { i18n } = require('./next-i18next.config.js');
|
|
const path = require('path');
|
|
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
const nextConfig = {
|
|
basePath: process.env.NEXT_PUBLIC_BASE_URL,
|
|
i18n,
|
|
output: 'standalone',
|
|
reactStrictMode: isDev ? false : true,
|
|
compress: true,
|
|
// 禁用 source map(可选,根据需要)
|
|
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, nextRuntime }) {
|
|
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.push('@node-rs/jieba');
|
|
|
|
if (nextRuntime === 'nodejs') {
|
|
}
|
|
} else {
|
|
config.resolve = {
|
|
...config.resolve,
|
|
fallback: {
|
|
...config.resolve.fallback,
|
|
fs: false
|
|
}
|
|
};
|
|
}
|
|
|
|
config.experiments = {
|
|
asyncWebAssembly: true,
|
|
layers: true
|
|
};
|
|
|
|
if (isDev && !isServer) {
|
|
// 使用更快的 source map
|
|
config.devtool = 'eval-cheap-module-source-map';
|
|
// 减少文件监听范围
|
|
config.watchOptions = {
|
|
...config.watchOptions,
|
|
ignored: ['**/node_modules', '**/.git', '**/dist', '**/coverage']
|
|
};
|
|
// 启用持久化缓存
|
|
config.cache = {
|
|
type: 'filesystem',
|
|
name: 'client',
|
|
buildDependencies: {
|
|
config: [__filename]
|
|
},
|
|
cacheDirectory: path.resolve(__dirname, '.next/cache/webpack'),
|
|
maxMemoryGenerations: isDev ? 5 : Infinity,
|
|
maxAge: 7 * 24 * 60 * 60 * 1000 // 7 天
|
|
};
|
|
}
|
|
|
|
return config;
|
|
},
|
|
// 需要转译的包
|
|
transpilePackages: ['@modelcontextprotocol/sdk', 'ahooks'],
|
|
serverExternalPackages: [
|
|
'mongoose',
|
|
'pg',
|
|
'bullmq',
|
|
'@zilliz/milvus2-sdk-node',
|
|
'tiktoken',
|
|
'@opentelemetry/api-logs'
|
|
],
|
|
experimental: {
|
|
outputFileTracingRoot: path.join(__dirname, '../../'),
|
|
workerThreads: true
|
|
}
|
|
};
|
|
|
|
module.exports = nextConfig;
|