@@ -54,7 +54,7 @@ export function constructWebpackConfigFunction(
54
54
) : WebpackConfigFunction {
55
55
// Will be called by nextjs and passed its default webpack configuration and context data about the build (whether
56
56
// 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.
58
58
const newWebpackFunction = ( incomingConfig : WebpackConfigObject , buildContext : BuildContext ) : WebpackConfigObject => {
59
59
let newConfig = { ...incomingConfig } ;
60
60
@@ -203,7 +203,7 @@ function addFileToExistingEntryPoint(
203
203
newEntryPoint = [ ...currentEntryPoint , filepath ] ;
204
204
}
205
205
// descriptor object (webpack 5+)
206
- else {
206
+ else if ( typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint ) {
207
207
const currentImportValue = currentEntryPoint . import ;
208
208
let newImportValue : string | string [ ] ;
209
209
@@ -217,6 +217,16 @@ function addFileToExistingEntryPoint(
217
217
...currentEntryPoint ,
218
218
import : newImportValue ,
219
219
} ;
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 ;
220
230
}
221
231
222
232
entryProperty [ entryPointName ] = newEntryPoint ;
0 commit comments