@@ -54,7 +54,7 @@ export function constructWebpackConfigFunction(
5454) : WebpackConfigFunction {
5555 // Will be called by nextjs and passed its default webpack configuration and context data about the build (whether
5656 // we're building server or client, whether we're in dev, what version of webpack we're using, etc). Note that
57- // `currentWebpackConfig ` and `buildContext` are referred to as `config` and `options` in the nextjs docs.
57+ // `incomingConfig ` and `buildContext` are referred to as `config` and `options` in the nextjs docs.
5858 const newWebpackFunction = ( incomingConfig : WebpackConfigObject , buildContext : BuildContext ) : WebpackConfigObject => {
5959 let newConfig = { ...incomingConfig } ;
6060
@@ -203,7 +203,7 @@ function addFileToExistingEntryPoint(
203203 newEntryPoint = [ ...currentEntryPoint , filepath ] ;
204204 }
205205 // descriptor object (webpack 5+)
206- else {
206+ else if ( typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint ) {
207207 const currentImportValue = currentEntryPoint . import ;
208208 let newImportValue : string | string [ ] ;
209209
@@ -217,6 +217,16 @@ function addFileToExistingEntryPoint(
217217 ...currentEntryPoint ,
218218 import : newImportValue ,
219219 } ;
220+ } else {
221+ // mimic the logger prefix in order to use `console.warn` (which will always be printed, regardless of SDK settings)
222+ // eslint-disable-next-line no-console
223+ console . error (
224+ 'Sentry Logger [Error]:' ,
225+ `Could not inject SDK initialization code into entry point ${ entryPointName } , as it is not a recognized format.\n` ,
226+ `Expected: string | Array<string> | { [key:string]: any, import: string | Array<string> }\n` ,
227+ `Got: ${ currentEntryPoint } ` ,
228+ ) ;
229+ return ;
220230 }
221231
222232 entryProperty [ entryPointName ] = newEntryPoint ;
0 commit comments