@@ -42,54 +42,13 @@ const requireFilesystemModule = (id: string, builtInExtensionsDir: string): any
42
42
return customMod . require ( id ) ;
43
43
} ;
44
44
45
- /**
46
- * Called from forking a module
47
- */
48
- export const requireFork = ( modulePath : string , args : string [ ] , builtInExtensionsDir : string ) : void => {
49
- const Module = require ( "module" ) as typeof import ( "module" ) ;
50
- const oldRequire = Module . prototype . require ;
51
- // tslint:disable-next-line:no-any
52
- const oldLoad = ( Module as any ) . _findPath ;
53
- // @ts -ignore
54
- ( Module as any ) . _findPath = function ( request , parent , isMain ) : any {
55
- const lookupPaths = oldLoad . call ( this , request , parent , isMain ) ;
56
-
57
- return lookupPaths ;
58
- } ;
59
- // tslint:disable-next-line:no-any
60
- Module . prototype . require = function ( id : string ) : any {
61
- if ( id === "typescript" ) {
62
- return require ( "typescript" ) ;
63
- }
64
-
65
- // tslint:disable-next-line:no-any
66
- return oldRequire . call ( this , id as any ) ;
67
- } ;
68
-
69
- if ( ! process . send ) {
70
- throw new Error ( "No IPC messaging initialized" ) ;
71
- }
72
-
73
- process . argv = [ "" , "" , ...args ] ;
74
- requireFilesystemModule ( modulePath , builtInExtensionsDir ) ;
75
-
76
- if ( ipcMsgBuffer && ipcMsgListener ) {
77
- process . removeListener ( "message" , ipcMsgListener ) ;
78
- // tslint:disable-next-line:no-any
79
- ipcMsgBuffer . forEach ( ( i ) => process . emit ( "message" as any , i as any ) ) ;
80
- ipcMsgBuffer = undefined ;
81
- ipcMsgListener = undefined ;
82
- }
83
- } ;
84
-
85
- export const requireModule = ( modulePath : string , dataDir : string , builtInExtensionsDir : string ) : void => {
45
+ export const requireModule = ( modulePath : string , builtInExtensionsDir : string ) : void => {
86
46
process . env . AMD_ENTRYPOINT = modulePath ;
87
47
const xml = require ( "xhr2" ) ;
88
48
xml . XMLHttpRequest . prototype . _restrictedHeaders [ "user-agent" ] = false ;
89
49
// tslint:disable-next-line no-any this makes installing extensions work.
90
50
( global as any ) . XMLHttpRequest = xml . XMLHttpRequest ;
91
51
92
- const mod = require ( "module" ) as typeof import ( "module" ) ;
93
52
const promiseFinally = require ( "promise.prototype.finally" ) as { shim : ( ) => void } ;
94
53
promiseFinally . shim ( ) ;
95
54
/**
@@ -102,16 +61,8 @@ export const requireModule = (modulePath: string, dataDir: string, builtInExtens
102
61
} ;
103
62
104
63
if ( isCli ) {
105
- /**
106
- * Needed for properly forking external modules within the CLI
107
- */
108
- // tslint:disable-next-line:no-any
109
- ( < any > cp ) . fork = ( modulePath : string , args : ReadonlyArray < string > = [ ] , options ?: cp . ForkOptions ) : cp . ChildProcess => {
110
- return cp . spawn ( process . execPath , [ path . join ( buildDir , "out" , "cli.js" ) , "--fork" , modulePath , "--extra-args" , JSON . stringify ( args ) , "--data-dir" , dataDir ] , {
111
- ...options ,
112
- stdio : [ null , null , null , "ipc" ] ,
113
- } ) ;
114
- } ;
64
+ // Needed for properly forking external modules within the CLI.
65
+ process . env . NBIN_BYPASS = "true" ;
115
66
}
116
67
117
68
const baseDir = path . join ( buildDir , "build" ) ;
0 commit comments