Skip to content

Commit b82178c

Browse files
committed
move computation that require global state into init-method
1 parent 0c1b0d1 commit b82178c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/core/scriptLoader.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,26 +183,28 @@ namespace AMDLoader {
183183
this._env = env;
184184
this._didInitialize = false;
185185
this._didPatchNodeRequire = false;
186-
187-
// js-flags have an impact on cached data
188-
this._jsflags = '';
189-
for (const arg of process.argv) {
190-
if (arg.indexOf('--js-flags=') === 0) {
191-
this._jsflags = arg;
192-
break;
193-
}
194-
}
195186
}
196187

197188
private _init(nodeRequire: INodeRequire): void {
198189
if (this._didInitialize) {
199190
return;
200191
}
201192
this._didInitialize = true;
193+
194+
// capture node modules
202195
this._fs = nodeRequire('fs');
203196
this._vm = nodeRequire('vm');
204197
this._path = nodeRequire('path');
205198
this._crypto = nodeRequire('crypto');
199+
200+
// js-flags have an impact on cached data
201+
this._jsflags = '';
202+
for (const arg of process.argv) {
203+
if (arg.indexOf('--js-flags=') === 0) {
204+
this._jsflags = arg;
205+
break;
206+
}
207+
}
206208
}
207209

208210
// patch require-function of nodejs such that we can manually create a script

0 commit comments

Comments
 (0)