-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: how can the values provided by process.platform and process.arch better reflect the underlying system #1236
Comments
FWIW I'm personally +1 on having different values there, and brought something similar up when first encountered too. Just one adjustment - the standard triplets for Wasm are
But I'm not a Stackblitz employee, just an opinionated Wasm developer :) |
Hey @lovell and @RReverser ! Thanks for starting this discussion! 😃 The original motivation for having
I totally agree. I don't see us changing I really like the idea of having This is something we (StackBlitz) should investigate. |
Note that |
Yeah I'd expect that only native modules care about |
Brilliant, thanks both, I agree that setting |
Thank you for all your work on WebContainers, they are really exciting technology. My thoughts below are about (hopefully) making the use of native modules slightly easier for the multiple parties involved.
The value currently provided by
process.arch
is alwaysx64
and the value provided byprocess.platform
is alwayslinux
.According to lovell/sharp#3750 (comment) "WebContainers specifically aims to comply with Linux behavior", however from what can tell, WebContainers do not expose or provide any underlying Linux APIs.
It looks like at least one other person has been confused and has questioned this, e.g. #1095 states unexpected behaviour: "...reports Linux x64 rather than the expected WASM"
Many native dependencies are either using or are migrating to the use of
optionalDependencies
withos
andcpu
filters to tell package managers to download only the relevant binaries. In the case of WebContainers, the current values on theprocess
global would imply the installation of a package and therefore native binary that defines the following filters:The current approach to deal with this appears to be that package maintainers should include custom logic via
@webcontainer/env
or that end-users must add Wasm-specific dependencies, or that StackBlitz will automagically polyfill certain dependencies.I feel like some consensus could be reached here around more appropriate values for
process.platform
andprocess.arch
to allow Node.js compatible WebAssembly runtimes to work with existing package manager logic rather than against it, and that perhaps StackBlitz could be able to lead this.Here's a very quick worked example (and it is only an example). Let's say
process.platform
iswasm
andprocess.arch
is32
. A maintainer of a native package might then be able to include the following in a publishedpackage.json
file to make it explicit that this is the relevant package to install and use with a Wasm32 runtime.The underlying aim for this question/discussion is an attempt to make life easier for StackBlitz (you can start to remove polyfills), make life easier for end-users (no manually-added Wasm-specific dependencies) and make life easier for package maintainers (the method already used for platform-specific binaries will "just work"). Thank you for reading.
The text was updated successfully, but these errors were encountered: