Gerrit Bot has uploaded this change for review.
misc/wasm: make wasm_exec.js supports enviroment without fs module
Some of the environment (e.g. Cloudflare Worker) maybe not support for "fs" module and returns 'Uncaught Error: No such module "fs".' error.
This changes can fix the issue.
Change-Id: I41ed8b65fd510d90fb8b72a94469f825093bcd00
GitHub-Last-Rev: 52d7dad0bc0f62d5a1c5e9ebe1813a02f7967f72
GitHub-Pull-Request: golang/go#48169
---
M misc/wasm/wasm_exec.js
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index 231185a..a629888 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -28,10 +28,12 @@
}
if (!global.fs && global.require) {
- const fs = require("fs");
- if (typeof fs === "object" && fs !== null && Object.keys(fs).length !== 0) {
- global.fs = fs;
- }
+ try {
+ const fs = require("fs");
+ if (typeof fs === "object" && fs !== null && Object.keys(fs).length !== 0) {
+ global.fs = fs;
+ }
+ } catch(e) {}
}
const enosys = () => {
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Richard Musiol, Cherry Mui.
Gerrit Bot uploaded patch set #2 to this change.
misc/wasm: make wasm_exec.js supports enviroment without fs module
Some of the environment (e.g. Cloudflare Worker) maybe not support for "fs" module and returns 'Uncaught Error: No such module "fs".' error.
This changes can fix the issue.
Change-Id: I41ed8b65fd510d90fb8b72a94469f825093bcd00
GitHub-Last-Rev: c56557b7a1e0b157679d4245f64da4103935887f
GitHub-Pull-Request: golang/go#48169
---
M misc/wasm/wasm_exec.js
1 file changed, 20 insertions(+), 12 deletions(-)
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Richard Musiol, Cherry Mui.
Gerrit Bot uploaded patch set #3 to this change.
misc/wasm: make wasm_exec.js try catch when require module
Some of the environment (e.g. Cloudflare Worker) maybe not support for "fs" module and returns 'Uncaught Error: No such module "fs".' error.
This changes can fix the issue.
Change-Id: I41ed8b65fd510d90fb8b72a94469f825093bcd00
GitHub-Last-Rev: c56557b7a1e0b157679d4245f64da4103935887f
GitHub-Pull-Request: golang/go#48169
---
M misc/wasm/wasm_exec.js
1 file changed, 20 insertions(+), 12 deletions(-)
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Richard Musiol, Cherry Mui.
Gerrit Bot uploaded patch set #4 to this change.
misc/wasm: make wasm_exec.js try catch when require module
Some of the environment (e.g. Cloudflare Worker) maybe not support for "fs" (or other modules) and returns 'Uncaught Error: No such module' error.
This changes can fix the issue.
Change-Id: I41ed8b65fd510d90fb8b72a94469f825093bcd00
GitHub-Last-Rev: c56557b7a1e0b157679d4245f64da4103935887f
GitHub-Pull-Request: golang/go#48169
---
M misc/wasm/wasm_exec.js
1 file changed, 20 insertions(+), 12 deletions(-)
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Cherry Mui.
1 comment:
Patchset:
I am reluctant to add support for yet another environment. Instead I wrote https://go-review.googlesource.com/c/go/+/347353. This should make it relatively easy for you to make it fit into the Cloudflare Worker environment, since wasm_exec.js itself is not using "require" any more. Please give it a try.
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: SerKo, Cherry Mui.
1 comment:
Patchset:
So that means when works on an another environment that not supported by native. […]
Exactly.
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Richard Musiol, Cherry Mui.
1 comment:
Patchset:
I am reluctant to add support for yet another environment. Instead I wrote https://go-review. […]
So that means when works on an another environment that not supported by native. Developer should create a new js file (like wasm_exec_node.js) that custom the polyfill function right?
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Richard Musiol, Cherry Mui.
2 comments:
Patchset:
Exactly.
Done
Exactly.
I think it's a good solution. Cheers!
To view, visit change 347170. To unsubscribe, or for help writing mail filters, visit settings.