1
0
mirror of https://github.com/golang/go synced 2024-11-11 19:51:37 -07:00

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: aecc847e3f
GitHub-Pull-Request: golang/go#35805
Reviewed-on: https://go-review.googlesource.com/c/go/+/208600
Reviewed-by: Richard Musiol <neelance@gmail.com>
This commit is contained in:
nao20010128nao 2020-03-21 06:52:58 +00:00 committed by Richard Musiol
parent f0e8b81aa3
commit 9ef61d58c0

View File

@ -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 = () => {