aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authornao20010128nao <nao20010128@gmail.com>2020-03-21 06:52:58 +0000
committerRichard Musiol <neelance@gmail.com>2020-03-24 10:33:13 +0000
commit9ef61d58c015e7bc297ed4404e34af5f3d514257 (patch)
treeeb94224580cf0a515478dd9c31c130ccd0169b07 /misc
parentf0e8b81aa34120e21642c569912bde00ccd33393 (diff)
downloadgo-9ef61d58c015e7bc297ed4404e34af5f3d514257.tar.gz
go-9ef61d58c015e7bc297ed4404e34af5f3d514257.zip
syscall/js: make wasm_exec.js compatible with Webpack
In Webpack, require("fs") will always be empty. This behavior throws an error: "fs.writeSync is not function". It happens when you did "fmt.Println". This PR avoids such problem and use polyfill in wasm_exec.js on Webpack. Change-Id: I55f2c75ce86b7f84d2d92e8e217b5decfbe3c8a1 GitHub-Last-Rev: aecc847e3f9d5617ea4b00196ef2810c2458f085 GitHub-Pull-Request: golang/go#35805 Reviewed-on: https://go-review.googlesource.com/c/go/+/208600 Reviewed-by: Richard Musiol <neelance@gmail.com>
Diffstat (limited to 'misc')
-rw-r--r--misc/wasm/wasm_exec.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index 8cb297f379..a99aaeda07 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -27,7 +27,10 @@
}
if (!global.fs && global.require) {
- global.fs = require("fs");
+ const fs = require("fs");
+ if (Object.keys(fs) !== 0) {
+ global.fs = fs;
+ }
}
const enosys = () => {