@@ -6,7 +6,6 @@ import * as path from 'path';
6
6
7
7
import {
8
8
BuildContext ,
9
- EntryPointValue ,
10
9
EntryPropertyObject ,
11
10
NextConfigObject ,
12
11
SentryWebpackPluginOptions ,
@@ -163,51 +162,52 @@ export function getUserConfigFile(projectDir: string, platform: 'server' | 'clie
163
162
}
164
163
165
164
/**
166
- * Add a file to a specific element of the given `entry` webpack config property.
165
+ * Add files to a specific element of the given `entry` webpack config property.
167
166
*
168
167
* @param entryProperty The existing `entry` config object
169
168
* @param entryPointName The key where the file should be injected
170
- * @param filepath The path to the injected file
169
+ * @param filepaths An array of paths to the injected files
171
170
*/
172
- function addFileToExistingEntryPoint (
171
+ function addFilesToExistingEntryPoint (
173
172
entryProperty : EntryPropertyObject ,
174
173
entryPointName : string ,
175
- filepath : string ,
174
+ filepaths : string [ ] ,
176
175
) : void {
177
176
// can be a string, array of strings, or object whose `import` property is one of those two
178
177
const currentEntryPoint = entryProperty [ entryPointName ] ;
179
- let newEntryPoint : EntryPointValue ;
178
+ let newEntryPoint = currentEntryPoint ;
180
179
181
180
if ( typeof currentEntryPoint === 'string' ) {
182
- newEntryPoint = [ filepath , currentEntryPoint ] ;
181
+ newEntryPoint = [ ... filepaths , currentEntryPoint ] ;
183
182
} else if ( Array . isArray ( currentEntryPoint ) ) {
184
- newEntryPoint = [ filepath , ...currentEntryPoint ] ;
183
+ newEntryPoint = [ ... filepaths , ...currentEntryPoint ] ;
185
184
}
186
185
// descriptor object (webpack 5+)
187
186
else if ( typeof currentEntryPoint === 'object' && 'import' in currentEntryPoint ) {
188
187
const currentImportValue = currentEntryPoint . import ;
189
188
let newImportValue ;
190
189
191
190
if ( typeof currentImportValue === 'string' ) {
192
- newImportValue = [ filepath , currentImportValue ] ;
191
+ newImportValue = [ ... filepaths , currentImportValue ] ;
193
192
} else {
194
- newImportValue = [ filepath , ...currentImportValue ] ;
193
+ newImportValue = [ ... filepaths , ...currentImportValue ] ;
195
194
}
196
195
197
196
newEntryPoint = {
198
197
...currentEntryPoint ,
199
198
import : newImportValue ,
200
199
} ;
201
- } else {
202
- // mimic the logger prefix in order to use `console.warn` (which will always be printed, regardless of SDK settings)
200
+ }
201
+ // malformed entry point (use `console.error` rather than `logger.error` because it will always be printed, regardless
202
+ // of SDK settings)
203
+ else {
203
204
// eslint-disable-next-line no-console
204
205
console . error (
205
206
'Sentry Logger [Error]:' ,
206
- `Could not inject SDK initialization code into entry point ${ entryPointName } , as it is not a recognized format.\n` ,
207
+ `Could not inject SDK initialization code into entry point ${ entryPointName } , as its current value is not in a recognized format.\n` ,
207
208
`Expected: string | Array<string> | { [key:string]: any, import: string | Array<string> }\n` ,
208
209
`Got: ${ currentEntryPoint } ` ,
209
210
) ;
210
- return ;
211
211
}
212
212
213
213
entryProperty [ entryPointName ] = newEntryPoint ;
0 commit comments