@@ -17,6 +17,8 @@ import { SERVER_SDK_INIT_PATH, storeServerConfigFileLocation } from './utils';
1717
1818export { SentryWebpackPlugin } ;
1919
20+ logger . enable ( ) ;
21+
2022// TODO: merge default SentryWebpackPlugin ignore with their SentryWebpackPlugin ignore or ignoreFile
2123// TODO: merge default SentryWebpackPlugin include with their SentryWebpackPlugin include
2224// TODO: drop merged keys from override check? `includeDefaults` option?
@@ -54,7 +56,7 @@ export function constructWebpackConfigFunction(
5456) : WebpackConfigFunction {
5557 // Will be called by nextjs and passed its default webpack configuration and context data about the build (whether
5658 // 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.
59+ // `incomingConfig ` and `buildContext` are referred to as `config` and `options` in the nextjs docs.
5860 const newWebpackFunction = ( incomingConfig : WebpackConfigObject , buildContext : BuildContext ) : WebpackConfigObject => {
5961 let newConfig = { ...incomingConfig } ;
6062
@@ -203,7 +205,7 @@ function addFileToExistingEntryPoint(
203205 newEntryPoint = [ ...currentEntryPoint , filepath ] ;
204206 }
205207 // descriptor object (webpack 5+)
206- else {
208+ else if ( typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint ) {
207209 const currentImportValue = currentEntryPoint . import ;
208210 let newImportValue : string | string [ ] ;
209211
@@ -217,6 +219,13 @@ function addFileToExistingEntryPoint(
217219 ...currentEntryPoint ,
218220 import : newImportValue ,
219221 } ;
222+ } else {
223+ logger . warn (
224+ `Could not inject SDK initialization code into entry point ${ entryPointName } , as it is not a recognized format.\n` ,
225+ `Expected: string | Array<string> | { [key:string]: any, import: string | Array<string> }\n` ,
226+ `Got: ${ currentEntryPoint } ` ,
227+ ) ;
228+ return ;
220229 }
221230
222231 entryProperty [ entryPointName ] = newEntryPoint ;
0 commit comments