PSA/ee/server/next.config.mjs
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

194 lines
9.1 KiB
JavaScript

import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Reusable path to an empty shim for optional/native modules (used by Turbopack aliases)
const emptyShim = './src/empty/shims/empty.ts';
// `ee/server` is the enterprise app, so default to EE wiring unless explicitly forced off.
const isEE = process.env.EDITION !== 'ce' && process.env.NEXT_PUBLIC_EDITION !== 'community';
const nextConfig = {
// Transpile shared product packages used by EE server
transpilePackages: [
'@product/extensions',
'@product/extensions-pages',
'@alga-psa/event-schemas',
'@alga-psa/core',
'@alga-psa/user-activities',
],
// Turbopack-specific aliases
turbopack: {
resolveAlias: {
'@': './src',
// EE source alias
'@ee/*': './src/*',
'@enterprise/*': './src/*',
'@enterprise': './src',
// Feature swap: product pages and entries
'@product/extensions/entry': isEE
? '../../packages/product-extensions/ee/entry'
: '../../packages/product-extensions/oss/entry',
'@product/extensions/pages/list': isEE
? '../../packages/product-extensions-pages/ee/list'
: '../../packages/product-extensions-pages/oss/list',
'@product/extensions/pages/details': isEE
? '../../packages/product-extensions-pages/ee/details'
: '../../packages/product-extensions-pages/oss/details',
'@product/extensions/pages/settings': isEE
? '../../packages/product-extensions-pages/ee/settings'
: '../../packages/product-extensions-pages/oss/settings',
'@product/ext-proxy/handler': isEE
? '../../packages/product-ext-proxy/ee/handler'
: '../../packages/product-ext-proxy/oss/handler',
'@alga-psa/integrations/entra/components/entry': isEE
? '../../packages/integrations/src/entra/components/ee/entry'
: '../../packages/integrations/src/entra/components/oss/entry',
'@alga-psa/integrations/entra/routes/entry': isEE
? '../../packages/integrations/src/entra/routes/ee/entry'
: '../../packages/integrations/src/entra/routes/oss/entry',
// Event schemas package
'@alga-psa/event-schemas': '../../packages/event-schemas/src',
'@alga-psa/event-schemas/': '../../packages/event-schemas/src/',
// SSO provider buttons - always use EE implementation in EE server
'@alga-psa/auth/sso/entry': './src/components/auth/SsoProviderButtons.tsx',
'@alga-psa/ee-stubs': './src',
'@alga-psa/ee-stubs/': './src/',
'@alga-psa/workflows/entry': './src/workflows/entry.tsx',
// user-activities workflow-task seam — EE app always uses the real implementations.
'@alga-psa/user-activities/server/workflow-tasks': './src/user-activities/workflowTasks.server.ts',
'@alga-psa/user-activities/client/workflow-tasks': './src/user-activities/workflowTasks.client.tsx',
'@alga-psa/product-extension-actions': '../../packages/product-extension-actions/ee/entry.ts',
'@alga-psa/product-extension-initialization': './src/lib/extensions/initialize.ts',
'@alga-psa/product-auth-ee': '../../packages/product-auth-ee/ee/entry.ts',
'@alga-psa/storage': '../../packages/storage/src',
'@alga-psa/storage/StorageService': '../../packages/storage/src/StorageService.ts',
'@/empty/workflows/entry': './src/empty/workflows/entry.tsx',
// Native DB drivers not used
'better-sqlite3': emptyShim,
'sqlite3': emptyShim,
'mysql': emptyShim,
'mysql2': emptyShim,
'oracledb': emptyShim,
'tedious': emptyShim,
},
},
experimental: {
// Allow importing code from outside this directory (monorepo OSS server code)
externalDir: true,
// Increase middleware body size limit for extension installs
middlewareClientMaxBodySize: '100mb',
},
images: {
// Avoid requiring the native `sharp` binary locally
unoptimized: true,
},
eslint: {
ignoreDuringBuilds: true,
},
productionBrowserSourceMaps: false,
reactStrictMode: true,
webpack: (config, { isServer }) => {
// NOTE: This webpack config is kept for fallback compatibility when Turbopack isn't used
// The equivalent settings are now configured in the turbopack section above
// Speed up builds
config.cache = true;
// Helpful aliases and module resolution
config.resolve = {
...config.resolve,
// Allow .js imports to resolve to TS sources in the monorepo
extensionAlias: {
'.js': ['.js', '.ts', '.tsx'],
},
alias: {
...config.resolve?.alias,
'@': path.join(__dirname, 'src'),
// Ensure EE imports resolve to this package's src (EE edition)
'@ee': path.join(__dirname, 'src'),
'@enterprise': path.join(__dirname, 'src'),
// Hard-pin common EE import paths used by CE SettingsPage
'@ee/lib/extensions/ExtensionComponentLoader': path.join(__dirname, 'src/lib/extensions/ExtensionComponentLoader.tsx'),
'@ee/components': path.join(__dirname, 'src/components'),
// Feature swap aliases (Webpack)
'@product/extensions/entry': isEE
? path.join(__dirname, '../../packages/product-extensions/ee/entry.tsx')
: path.join(__dirname, '../../packages/product-extensions/oss/entry.tsx'),
'@product/extensions/pages/list': isEE
? path.join(__dirname, '../../packages/product-extensions-pages/ee/list.tsx')
: path.join(__dirname, '../../packages/product-extensions-pages/oss/list.tsx'),
'@product/extensions/pages/details': isEE
? path.join(__dirname, '../../packages/product-extensions-pages/ee/details.tsx')
: path.join(__dirname, '../../packages/product-extensions-pages/oss/details.tsx'),
'@product/extensions/pages/settings': isEE
? path.join(__dirname, '../../packages/product-extensions-pages/ee/settings.tsx')
: path.join(__dirname, '../../packages/product-extensions-pages/oss/settings.tsx'),
'@product/ext-proxy/handler': isEE
? path.join(__dirname, '../../packages/product-ext-proxy/ee/handler.ts')
: path.join(__dirname, '../../packages/product-ext-proxy/oss/handler.ts'),
'@alga-psa/integrations/entra/components/entry': isEE
? path.join(__dirname, '../../packages/integrations/src/entra/components/ee/entry.tsx')
: path.join(__dirname, '../../packages/integrations/src/entra/components/oss/entry.tsx'),
'@alga-psa/integrations/entra/routes/entry': isEE
? path.join(__dirname, '../../packages/integrations/src/entra/routes/ee/entry.ts')
: path.join(__dirname, '../../packages/integrations/src/entra/routes/oss/entry.ts'),
// Event schemas package
'@alga-psa/event-schemas': path.join(__dirname, '../../packages/event-schemas/src'),
// SSO provider buttons - always use EE implementation in EE server
'@alga-psa/auth/sso/entry': path.join(__dirname, 'src/components/auth/SsoProviderButtons.tsx'),
'@alga-psa/ee-stubs': path.join(__dirname, 'src'),
'@alga-psa/ee-stubs/': path.join(__dirname, 'src/'),
'@alga-psa/workflows/entry': path.join(__dirname, 'src/workflows/entry.tsx'),
// user-activities workflow-task seam — EE app always uses the real implementations.
'@alga-psa/user-activities/server/workflow-tasks': path.join(__dirname, 'src/user-activities/workflowTasks.server.ts'),
'@alga-psa/user-activities/client/workflow-tasks': path.join(__dirname, 'src/user-activities/workflowTasks.client.tsx'),
'@alga-psa/product-extension-actions': path.join(__dirname, '../../packages/product-extension-actions/ee/entry.ts'),
'@alga-psa/product-extension-initialization': path.join(__dirname, 'src/lib/extensions/initialize.ts'),
'@alga-psa/product-auth-ee': path.join(__dirname, '../../packages/product-auth-ee/ee/entry.ts'),
'@alga-psa/storage': path.join(__dirname, '../../packages/storage/src'),
'@alga-psa/storage/StorageService': path.join(__dirname, '../../packages/storage/src/StorageService.ts'),
'@/empty/workflows/entry': path.join(__dirname, 'src/empty/workflows/entry.tsx'),
// Stub native sharp during local dev to avoid platform build issues
sharp: path.join(__dirname, 'src/empty/sharp.ts'),
},
modules: [
...(config.resolve?.modules || ['node_modules']),
// Root workspace node_modules
path.join(__dirname, '../../node_modules'),
],
};
// Exclude optional DB drivers not used (prevents bundling/resolve errors)
config.externals = [
...(config.externals || []),
'oracledb',
'mysql',
'mysql2',
'sqlite3',
'better-sqlite3',
'tedious',
];
// Treat .mjs in node_modules as JS auto
config.module.rules.push({
test: /\.mjs$/,
include: /node_modules/,
type: 'javascript/auto',
resolve: { fullySpecified: false },
});
// Exclude flow CSS modules that can cause build issues
config.module.rules.push({
test: /\.module\.css$/,
include: path.resolve(__dirname, 'src/components/flow'),
use: 'null-loader',
});
return config;
},
};
export default nextConfig;