Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 1919b36

Browse files
authored
fix: access process through _global so that WebPack does not accidently browserify (#786)
1 parent 89f990a commit 1919b36

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: lib/common/utils.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,20 @@ export function patchPrototype(prototype: any, fnNames: string[]) {
4747
export const isWebWorker: boolean =
4848
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope);
4949

50+
// Make sure to access `process` through `_global` so that WebPack does not accidently browserify
51+
// this code.
5052
export const isNode: boolean =
51-
(!('nw' in _global) && typeof process !== 'undefined' &&
52-
{}.toString.call(process) === '[object process]');
53+
(!('nw' in _global) && typeof _global.process !== 'undefined' &&
54+
{}.toString.call(_global.process) === '[object process]');
5355

5456
export const isBrowser: boolean =
5557
!isNode && !isWebWorker && !!(typeof window !== 'undefined' && (window as any)['HTMLElement']);
5658

5759
// we are in electron of nw, so we are both browser and nodejs
58-
export const isMix: boolean = typeof process !== 'undefined' &&
59-
{}.toString.call(process) === '[object process]' && !isWebWorker &&
60+
// Make sure to access `process` through `_global` so that WebPack does not accidently browserify
61+
// this code.
62+
export const isMix: boolean = typeof _global.process !== 'undefined' &&
63+
{}.toString.call(_global.process) === '[object process]' && !isWebWorker &&
6064
!!(typeof window !== 'undefined' && (window as any)['HTMLElement']);
6165

6266
export function patchProperty(obj: any, prop: string, prototype?: any) {

0 commit comments

Comments
 (0)