Skip to content

wasm: patch wasm_exec.js and wasm_exec_node.js from Go 1.18+#5483

Open
Darckfast wants to merge 1 commit into
tinygo-org:devfrom
Darckfast:port-go-wasm-exec-changes
Open

wasm: patch wasm_exec.js and wasm_exec_node.js from Go 1.18+#5483
Darckfast wants to merge 1 commit into
tinygo-org:devfrom
Darckfast:port-go-wasm-exec-changes

Conversation

@Darckfast

Copy link
Copy Markdown

Port these commits:
golang/go@680caf1 Removes polyfills from wasm_exec.js

The list of environments to support with wasm_exec.js was becoming too
large to maintain. With this change, wasm_exec.js expects that the
environment provides all necessary polyfills.

The standardized "globalThis" is used for accessing the environment.
wasm_exec.js now only provides stub fallbacks for globalThis.fs and
globalThis.process.

All code specific to Node.js is now in a separate file.

golang/go@04d8d24 Enables ECMAScript strict mode on wasm_exec.js

Current wasm_exec.js does not enable ECMAScript strict mode. But it is
recommended to be enabled because it

1. eliminates some ECMAScript silent errors by changing them to throw
   errors
2. fixes mistakes that make it difficult for JavaScript engines to
   perform optimizations
3. prohibits some syntax likely to be defined in future versions of
   ECMAScript

golang/go@ff34676 Replace deprecated substr with substring

String.prototype.substr is deprecated and usage is no longer
recommended so using String.prototype.substring instead.

this fixes #5370

NOTE: i added some polyfill on wasmexit.js,wasmfunc.js and wasmfunc.js tests files to keep compatibility with node 18

Port this commit golang/go@680caf1 removing polyfills from `wasm_exec.js`, now the environment is expected to provide all the required polyfills.

`wasm_exec.js` now only provides stub fallbacks for globalThis.fs and globalThis.process.

All NodeJS specific code is now in a separate file `wasm_exec_node.js` with its required polyfills.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wasm_exec.js doesn't play well with CloudFlare workers

1 participant