-
Notifications
You must be signed in to change notification settings - Fork 409
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
Request: Add portable ESM build target #676
Comments
Sort of related is the idea of |
I did some research, and found a surprising thing: it works almost as is with
and got if (module instanceof URL || typeof module === 'string' || module instanceof Request) { to if (module instanceof URL || typeof module === 'string') { and it worked! So we almost have this feature... almost, because of |
Actually importing Regardless a portable module doesn't even necessarily need to know anything about that, it just needs to have some source text with the right exports. If if (typeof module === 'string'
/* Node supports URL but not all hosts necessarily will e.g. XS */
|| typeof URL !== 'undefined' && module instanceof URL
|| typeof Request !== 'undefined' && module instanceof Request) { |
@Jamesernator I think that I think that means that this is actually fixed, so I'm going to close this. |
💡 Feature description
Currently there's 3 main build targets all that require different platforms, however there is no module target that is platform independent.
I'd like to propose adding a new target
--target module
that generates an ESM module similar to web but does not include any web specific things likefetch
/Request
/etc that make it unportable to Node (once it supports ESM) or other environments in future.In order to be as environment independent as possible I would propose outputting a module that imports no other modules (so that it doesn't tie down to specifier dependency) and also only rely on ecma262 builtin functions + WebAssembly globals.
In order to do this I would propose that this target would output a file similar to the current
--target web
but would instead of fetching the module itself ininit
it could instead just be passed aWebAssembly.Module
directly and then theinit
function could then use theWebAssembly.instantiate
function to instantiate it.💻 Basic example
Using such a module from the browser:
Or using such a module in Node (under experimental modules):
The text was updated successfully, but these errors were encountered: