@@ -17,6 +17,8 @@ import { SERVER_SDK_INIT_PATH, storeServerConfigFileLocation } from './utils';
17
17
18
18
export { SentryWebpackPlugin } ;
19
19
20
+ logger . enable ( ) ;
21
+
20
22
// TODO: merge default SentryWebpackPlugin ignore with their SentryWebpackPlugin ignore or ignoreFile
21
23
// TODO: merge default SentryWebpackPlugin include with their SentryWebpackPlugin include
22
24
// TODO: drop merged keys from override check? `includeDefaults` option?
@@ -54,7 +56,7 @@ export function constructWebpackConfigFunction(
54
56
) : WebpackConfigFunction {
55
57
// Will be called by nextjs and passed its default webpack configuration and context data about the build (whether
56
58
// 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.
58
60
const newWebpackFunction = ( incomingConfig : WebpackConfigObject , buildContext : BuildContext ) : WebpackConfigObject => {
59
61
let newConfig = { ...incomingConfig } ;
60
62
@@ -203,7 +205,7 @@ function addFileToExistingEntryPoint(
203
205
newEntryPoint = [ ...currentEntryPoint , filepath ] ;
204
206
}
205
207
// descriptor object (webpack 5+)
206
- else {
208
+ else if ( typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint ) {
207
209
const currentImportValue = currentEntryPoint . import ;
208
210
let newImportValue : string | string [ ] ;
209
211
@@ -217,6 +219,13 @@ function addFileToExistingEntryPoint(
217
219
...currentEntryPoint ,
218
220
import : newImportValue ,
219
221
} ;
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 ;
220
229
}
221
230
222
231
entryProperty [ entryPointName ] = newEntryPoint ;
0 commit comments