File tree Expand file tree Collapse file tree 5 files changed +14
-11
lines changed Expand file tree Collapse file tree 5 files changed +14
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
5
+ - [ utils] : ` bundlerSafeRequire ` renamed to ` dynamicRequire ` now takes two arguments, first is should be ` module ` , second ` request ` / ` moduleName ` .
6
+
5
7
## 4.2.2
6
8
7
9
- [ core] : Several internal fixes regarding integration, exports and domain.
Original file line number Diff line number Diff line change 8
8
Severity ,
9
9
} from '@sentry/types' ;
10
10
import { logger } from '@sentry/utils/logger' ;
11
- import { bundlerSafeRequire , getGlobalObject , uuid4 } from '@sentry/utils/misc' ;
11
+ import { dynamicRequire , getGlobalObject , uuid4 } from '@sentry/utils/misc' ;
12
12
import { Carrier , Layer } from './interfaces' ;
13
13
import { Scope } from './scope' ;
14
14
@@ -334,10 +334,10 @@ export function getCurrentHub(): Hub {
334
334
335
335
// Prefer domains over global if they are there
336
336
try {
337
- // We need to use `bundlerSafeRequire ` because `require` on it's own will be optimized by webpack.
338
- // We do not want this to happen, we need to try `require` the domain node module and fail if we are in browser
337
+ // We need to use `dynamicRequire ` because `require` on it's own will be optimized by webpack.
338
+ // We do not want this to happen, we need to try to `require` the domain node module and fail if we are in browser
339
339
// for example so we do not have to shim it and use `getCurrentHub` universally.
340
- const domain = bundlerSafeRequire ( 'domain' ) ;
340
+ const domain = dynamicRequire ( module , 'domain' ) ;
341
341
const activeDomain = domain . active ;
342
342
343
343
// If there no active domain, just return global hub
Original file line number Diff line number Diff line change 48
48
"fix" : " run-s fix:tslint fix:prettier" ,
49
49
"fix:prettier" : " prettier --write '{src,test}/**/*.ts'" ,
50
50
"fix:tslint" : " tslint --fix -t stylish -p ." ,
51
- "test" : " jest" ,
51
+ "test" : " run-s test:jest test:express" ,
52
+ "test:jest" : " jest" ,
52
53
"test:watch" : " jest --watch --notify" ,
54
+ "test:express" : " node test/manual/express.js" ,
53
55
"version" : " node ../../scripts/versionbump.js src/version.ts"
54
56
},
55
57
"jest" : {
Original file line number Diff line number Diff line change 19
19
20
20
## General
21
21
22
- Common utilities used by the Sentry JavaScript SDKs. ** Warning, only submodule imports are allowed here.**
22
+ Common utilities used by the Sentry JavaScript SDKs. ** Warning, only submodule imports are allowed here.** Also note,
23
+ this function shouldn't be used externally, we will break them from time to time. This package is not part of our public
24
+ API contract, we use them only internally.
Original file line number Diff line number Diff line change @@ -6,11 +6,8 @@ import { isString } from './is';
6
6
*
7
7
* @param request The module path to resolve
8
8
*/
9
- export function bundlerSafeRequire ( request : string ) : any {
10
- // We need to do this check for global.module || module here because if we are calling this inside a
11
- // active domain, global.module is undefined.
12
- // tslint:disable-next-line
13
- return ( ( getGlobalObject ( ) as any ) . module || module ) . require ( request ) ;
9
+ export function dynamicRequire ( mod : NodeModule , request : string ) : any {
10
+ return mod . require ( request ) ;
14
11
}
15
12
16
13
/**
You can’t perform that action at this time.
0 commit comments