@@ -2,6 +2,7 @@ import * as fs from 'fs';
2
2
import * as os from 'os' ;
3
3
import * as path from 'path' ;
4
4
import * as rimraf from 'rimraf' ;
5
+ import { DefinePlugin } from 'webpack' ;
5
6
6
7
import { withSentryConfig } from '../src/config' ;
7
8
import {
@@ -326,6 +327,43 @@ describe('webpack config', () => {
326
327
) ;
327
328
} ) ;
328
329
} ) ;
330
+
331
+ describe ( '`distDir` value in default server-side `RewriteFrames` integration' , ( ) => {
332
+ describe ( '`DefinePlugin` existence and inclusion of `__rewriteFramesDistDir__` definition' , ( ) => {
333
+ it . each ( [
334
+ [ 'no custom `distDir`, pre-existing `DefinePlugin`' , undefined , true ] ,
335
+ [ 'no custom `distDir`, no pre-existing `DefinePlugin`' , undefined , false ] ,
336
+ [ 'custom `distDir`, pre-existing `DefinePlugin`' , 'some/output/directory' , true ] ,
337
+ [ 'custom `distDir`, no pre-existing `DefinePlugin`' , 'some/output/directory' , false ] ,
338
+ ] ) (
339
+ '%s' ,
340
+ async ( _testTitle : string , customDistDir : string | undefined , existingDefinePlugin : boolean ) : Promise < void > => {
341
+ const userNextConfigMaybeWithDistDir = {
342
+ ...userNextConfig ,
343
+ ...( customDistDir && { distDir : customDistDir } ) ,
344
+ } ;
345
+ const serverWebpackConfigMaybeWithDefinePlugin = {
346
+ ...serverWebpackConfig ,
347
+ ...( existingDefinePlugin && { plugins : [ new DefinePlugin ( { __dogName__ : 'Maisey' } ) ] } ) ,
348
+ } ;
349
+
350
+ const finalWebpackConfig = await materializeFinalWebpackConfig ( {
351
+ userNextConfig : userNextConfigMaybeWithDistDir ,
352
+ incomingWebpackConfig : serverWebpackConfigMaybeWithDefinePlugin ,
353
+ incomingWebpackBuildContext : getBuildContext ( 'server' , userNextConfigMaybeWithDistDir ) ,
354
+ } ) ;
355
+
356
+ expect ( finalWebpackConfig . plugins ) . toEqual ( expect . arrayContaining ( [ expect . any ( DefinePlugin ) ] ) ) ;
357
+
358
+ const definePluginInstance = findWebpackPlugin ( finalWebpackConfig , 'DefinePlugin' ) as DefinePlugin ;
359
+ expect ( definePluginInstance . definitions . __rewriteFramesDistDir__ ) . toEqual ( customDistDir ) ;
360
+ } ,
361
+ ) ;
362
+ } ) ;
363
+ describe ( '`RewriteFrames` ends up with correct `distDir` value' , ( ) => {
364
+ // TODO: this, along with any number of other parts of the build process, should be tested with an integration test
365
+ } ) ;
366
+ } ) ;
329
367
} ) ;
330
368
331
369
describe ( 'Sentry webpack plugin config' , ( ) => {
0 commit comments