File tree Expand file tree Collapse file tree 5 files changed +61
-17
lines changed
test/manual/webpack-domain Expand file tree Collapse file tree 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');
22const path = require ( 'path' ) ;
33const webpack = require ( 'webpack' ) ;
44const { JSDOM } = require ( 'jsdom' ) ;
5- // runTests();
5+
66webpack (
77 {
88 entry : path . join ( __dirname , 'test-code.js' ) ,
99 output : {
1010 path : __dirname ,
1111 filename : 'tmp.js' ,
1212 } ,
13- // resolve: {
14- // mainFields: ['main'],
15- // },
1613 mode : 'development' ,
1714 } ,
1815 ( err , stats ) => {
@@ -28,10 +25,12 @@ webpack(
2825
2926 if ( stats . hasErrors ( ) ) {
3027 console . error ( info . errors ) ;
28+ process . exit ( 1 ) ;
3129 }
3230
3331 if ( stats . hasWarnings ( ) ) {
3432 console . warn ( info . warnings ) ;
33+ process . exit ( 1 ) ;
3534 }
3635
3736 runTests ( ) ;
Original file line number Diff line number Diff line change 6060 "test:jest" : " jest" ,
6161 "test:watch" : " jest --watch" ,
6262 "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" ,
6464 "version" : " node ../../scripts/versionbump.js src/version.ts"
6565 },
6666 "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 {
2020 } ;
2121}
2222
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+
2333/**
2434 * Checks whether we're in the Node.js or Browser environment
2535 *
@@ -365,8 +375,7 @@ const performanceFallback: CrossPlatformPerformance = {
365375export const crossPlatformPerformance : CrossPlatformPerformance = ( ( ) => {
366376 if ( isNodeEnv ( ) ) {
367377 try {
368- const req = require ;
369- const perfHooks = req ( 'perf_hooks' ) as { performance : CrossPlatformPerformance } ;
378+ const perfHooks = dynamicRequire ( module , 'perf_hooks' ) as { performance : CrossPlatformPerformance } ;
370379 return perfHooks . performance ;
371380 } catch ( _ ) {
372381 return performanceFallback ;
You can’t perform that action at this time.
0 commit comments