enable using esbuild with deno and wasm #2359
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The native implementation of esbuild is much faster than the WebAssembly version, but some people don't want to give Deno the
--allow-run
permission necessary to run esbuild and are ok waiting longer for their builds to finish when using the WebAssembly backend. With this PR, you can now use esbuild via WebAssembly in Deno. To do this you will need to import fromwasm.js
instead ofmod.js
:Make sure you run Deno with
--allow-net
so esbuild can download the WebAssembly module. Using esbuild like this starts up a worker thread that runs esbuild in parallel (unless you callesbuild.initialize({ worker: false })
to tell esbuild to run on the main thread). If you want to, you can callesbuild.stop()
to terminate the worker if you won't be using esbuild anymore and you want to reclaim the memory.Note that Deno appears to have a bug where background WebAssembly optimization can prevent the process from exiting for many seconds. If you are trying to use Deno and WebAssembly to run esbuild quickly, you may need to manually call
Deno.exit(0)
after your code has finished running.Fixes #2323