File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
main/scala/org/scalajs/jsenv/jsdomnodejs
test/scala/org/scalajs/jsenv/jsdomnodejs Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,9 @@ class JSDOMNodeJSEnv(config: JSDOMNodeJSEnv.Config) extends JSEnv {
111
111
});
112
112
113
113
var window = dom.window;
114
- window["scalajsCom"] = global.scalajsCom;
114
+ ["scalajsCom", "require"].forEach(name => {
115
+ window[name] = global[name];
116
+ });
115
117
116
118
var scriptsSrcs = $scriptsURIsJSArray;
117
119
for (var i = 0; i < scriptsSrcs.length; i++) {
Original file line number Diff line number Diff line change @@ -22,4 +22,17 @@ class JSDOMNodeJSEnvTest {
22
22
.expectOut(" http://localhost/foo\n " )
23
23
}
24
24
}
25
+
26
+ @ Test
27
+ def nodejsRequire : Unit = {
28
+ kit.withRun(
29
+ // language=JavaScript
30
+ """
31
+ const fs = require("fs");
32
+ console.log(fs != null);
33
+ console.log(typeof fs.write === "function");
34
+ """ ) { run =>
35
+ run.expectOut(" true\n " )
36
+ }
37
+ }
25
38
}
You can’t perform that action at this time.
0 commit comments