Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/nextjs/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export type NextConfigObject = {
productionBrowserSourceMaps?: boolean;
// https://nextjs.org/docs/pages/api-reference/next-config-js/env
env?: Record<string, string>;
serverExternalPackages?: string[];
};

export type SentryBuildOptions = {
Expand Down
33 changes: 33 additions & 0 deletions packages/nextjs/src/config/withSentryConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,35 @@ import { constructWebpackConfigFunction } from './webpack';
let showedExportModeTunnelWarning = false;
let showedExperimentalBuildModeWarning = false;

// Packages we auto-instrument need to be external for instrumentation to work
// Next.js externalizes some packages by default, see: https://nextjs.org/docs/app/api-reference/config/next-config-js/serverExternalPackages
// Others we need to add ourselves
const DEFAULT_SERVER_EXTERNAL_PACKAGES = [
'ai',
'amqplib',
'connect',
'dataloader',
'express',
'generic-pool',
'graphql',
'@hapi/hapi',
'ioredis',
'kafkajs',
'koa',
'lru-memoizer',
'mongodb',
'mongoose',
'mysql',
'mysql2',
'knex',
'pg',
'pg-pool',
'@node-redis/client',
'@redis/client',
'redis',
'tedious',
];

/**
* Modifies the passed in Next.js configuration with automatic build-time instrumentation and source map upload.
*
Expand Down Expand Up @@ -229,6 +258,10 @@ function getFinalConfigObject(

return {
...incomingUserNextConfigObject,
serverExternalPackages: [
...(incomingUserNextConfigObject.serverExternalPackages || []),
...DEFAULT_SERVER_EXTERNAL_PACKAGES,
],
webpack: constructWebpackConfigFunction(incomingUserNextConfigObject, userSentryOptions, releaseName),
};
}
Expand Down
Loading