File tree 5 files changed +61
-17
lines changed
test/manual/webpack-domain
5 files changed +61
-17
lines changed Original file line number Diff line number Diff line change @@ -2,17 +2,14 @@ const fs = require('fs');
2
2
const path = require ( 'path' ) ;
3
3
const webpack = require ( 'webpack' ) ;
4
4
const { JSDOM } = require ( 'jsdom' ) ;
5
- // runTests();
5
+
6
6
webpack (
7
7
{
8
8
entry : path . join ( __dirname , 'test-code.js' ) ,
9
9
output : {
10
10
path : __dirname ,
11
11
filename : 'tmp.js' ,
12
12
} ,
13
- // resolve: {
14
- // mainFields: ['main'],
15
- // },
16
13
mode : 'development' ,
17
14
} ,
18
15
( err , stats ) => {
@@ -28,10 +25,12 @@ webpack(
28
25
29
26
if ( stats . hasErrors ( ) ) {
30
27
console . error ( info . errors ) ;
28
+ process . exit ( 1 ) ;
31
29
}
32
30
33
31
if ( stats . hasWarnings ( ) ) {
34
32
console . warn ( info . warnings ) ;
33
+ process . exit ( 1 ) ;
35
34
}
36
35
37
36
runTests ( ) ;
Original file line number Diff line number Diff line change 60
60
"test:jest" : " jest" ,
61
61
"test:watch" : " jest --watch" ,
62
62
"test:express" : " node test/manual/express-scope-separation/start.js" ,
63
- "test:webpack" : " cd test/manual/webpack-domain/ && yarn && yarn webpack && node dist/bundle .js" ,
63
+ "test:webpack" : " cd test/manual/webpack-domain/ && yarn && node npm-build .js" ,
64
64
"version" : " node ../../scripts/versionbump.js src/version.ts"
65
65
},
66
66
"jest" : {
Original file line number Diff line number Diff line change
1
+ const path = require ( 'path' ) ;
2
+ const webpack = require ( 'webpack' ) ;
3
+ const { execSync } = require ( 'child_process' ) ;
4
+
5
+ // prettier-ignore
6
+ webpack (
7
+ {
8
+ entry : './index.js' ,
9
+ output : {
10
+ path : path . resolve ( __dirname , 'dist' ) ,
11
+ filename : 'bundle.js' ,
12
+ } ,
13
+ target : 'node' ,
14
+ mode : 'development' ,
15
+ } ,
16
+ function ( err , stats ) {
17
+ if ( err ) {
18
+ console . error ( err . stack || err ) ;
19
+ if ( err . details ) {
20
+ console . error ( err . details ) ;
21
+ }
22
+ return ;
23
+ }
24
+
25
+ const info = stats . toJson ( ) ;
26
+
27
+ if ( stats . hasErrors ( ) ) {
28
+ console . error ( info . errors ) ;
29
+ process . exit ( 1 ) ;
30
+ }
31
+
32
+ if ( stats . hasWarnings ( ) ) {
33
+ console . warn ( info . warnings ) ;
34
+ process . exit ( 1 ) ;
35
+ }
36
+ runTests ( ) ;
37
+ }
38
+ ) ;
39
+
40
+ function runTests ( ) {
41
+ try {
42
+ execSync ( 'node ' + path . resolve ( __dirname , 'dist' , 'bundle.js' ) ) ;
43
+ } catch ( _ ) {
44
+ process . exit ( 1 ) ;
45
+ }
46
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -20,6 +20,16 @@ interface SentryGlobal {
20
20
} ;
21
21
}
22
22
23
+ /**
24
+ * Requires a module which is protected against bundler minification.
25
+ *
26
+ * @param request The module path to resolve
27
+ */
28
+ export function dynamicRequire ( mod : any , request : string ) : any {
29
+ // tslint:disable-next-line: no-unsafe-any
30
+ return mod . require ( request ) ;
31
+ }
32
+
23
33
/**
24
34
* Checks whether we're in the Node.js or Browser environment
25
35
*
@@ -365,8 +375,7 @@ const performanceFallback: CrossPlatformPerformance = {
365
375
export const crossPlatformPerformance : CrossPlatformPerformance = ( ( ) => {
366
376
if ( isNodeEnv ( ) ) {
367
377
try {
368
- const req = require ;
369
- const perfHooks = req ( 'perf_hooks' ) as { performance : CrossPlatformPerformance } ;
378
+ const perfHooks = dynamicRequire ( module , 'perf_hooks' ) as { performance : CrossPlatformPerformance } ;
370
379
return perfHooks . performance ;
371
380
} catch ( _ ) {
372
381
return performanceFallback ;
You can’t perform that action at this time.
0 commit comments