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 22
33## Unreleased
44
5+ - [ utils] : ` bundlerSafeRequire ` renamed to ` dynamicRequire ` now takes two arguments, first is should be ` module ` , second ` request ` / ` moduleName ` .
6+
57## 4.2.2
68
79- [ core] : Several internal fixes regarding integration, exports and domain.
Original file line number Diff line number Diff line change 88 Severity ,
99} from '@sentry/types' ;
1010import { logger } from '@sentry/utils/logger' ;
11- import { bundlerSafeRequire , getGlobalObject , uuid4 } from '@sentry/utils/misc' ;
11+ import { dynamicRequire , getGlobalObject , uuid4 } from '@sentry/utils/misc' ;
1212import { Carrier , Layer } from './interfaces' ;
1313import { Scope } from './scope' ;
1414
@@ -334,10 +334,10 @@ export function getCurrentHub(): Hub {
334334
335335 // Prefer domains over global if they are there
336336 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
339339 // 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' ) ;
341341 const activeDomain = domain . active ;
342342
343343 // If there no active domain, just return global hub
Original file line number Diff line number Diff line change 4848 "fix" : " run-s fix:tslint fix:prettier" ,
4949 "fix:prettier" : " prettier --write '{src,test}/**/*.ts'" ,
5050 "fix:tslint" : " tslint --fix -t stylish -p ." ,
51- "test" : " jest" ,
51+ "test" : " run-s test:jest test:express" ,
52+ "test:jest" : " jest" ,
5253 "test:watch" : " jest --watch --notify" ,
54+ "test:express" : " node test/manual/express.js" ,
5355 "version" : " node ../../scripts/versionbump.js src/version.ts"
5456 },
5557 "jest" : {
Original file line number Diff line number Diff line change 1919
2020## General
2121
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';
66 *
77 * @param request The module path to resolve
88 */
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 ) ;
1411}
1512
1613/**
You can’t perform that action at this time.
0 commit comments