diff options
author | Bradley Farias <bradley.meck@gmail.com> | 2017-06-05 19:44:56 -0500 |
---|---|---|
committer | Bradley Farias <bradley.meck@gmail.com> | 2017-09-07 15:18:32 -0500 |
commit | c8a389e19f172edbada83f59944cad7cc802d9d5 (patch) | |
tree | 15a8653683a97ff0d6b2e7f08ef8081405700ea3 /src/module_wrap.h | |
parent | 46133b5beba2c780fb3b9a9d6be610d09f752182 (diff) | |
download | android-node-v8-c8a389e19f172edbada83f59944cad7cc802d9d5.tar.gz android-node-v8-c8a389e19f172edbada83f59944cad7cc802d9d5.tar.bz2 android-node-v8-c8a389e19f172edbada83f59944cad7cc802d9d5.zip |
module: Allow runMain to be ESM
This follows the EPS an allows the node CLI to have ESM as an entry point.
`node ./example.mjs`. A newer V8 is needed for `import()` so that is not
included. `import.meta` is still in specification stage so that also is not
included.
PR-URL: https://github.com/nodejs/node/pull/14369
Author: Bradley Farias <bradley.meck@gmail.com>
Author: Guy Bedford <guybedford@gmail.com>
Author: Jan Krems <jan.krems@groupon.com>
Author: Timothy Gu <timothygu99@gmail.com>
Author: Michaƫl Zasso <targos@protonmail.com>
Author: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'src/module_wrap.h')
-rw-r--r-- | src/module_wrap.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/module_wrap.h b/src/module_wrap.h new file mode 100644 index 0000000000..c669834c6f --- /dev/null +++ b/src/module_wrap.h @@ -0,0 +1,58 @@ +#ifndef SRC_MODULE_WRAP_H_ +#define SRC_MODULE_WRAP_H_ + +#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#include <map> +#include <string> +#include <vector> +#include "node_url.h" +#include "base-object.h" +#include "base-object-inl.h" + +namespace node { +namespace loader { + +node::url::URL Resolve(std::string specifier, node::url::URL* base, + bool read_pkg_json = false); + +class ModuleWrap : public BaseObject { + public: + static const std::string EXTENSIONS[]; + static void Initialize(v8::Local<v8::Object> target, + v8::Local<v8::Value> unused, + v8::Local<v8::Context> context); + + private: + ModuleWrap(node::Environment* env, + v8::Local<v8::Object> object, + v8::Local<v8::Module> module, + v8::Local<v8::String> url); + ~ModuleWrap(); + + static void New(const v8::FunctionCallbackInfo<v8::Value>& args); + static void Link(const v8::FunctionCallbackInfo<v8::Value>& args); + static void Instantiate(const v8::FunctionCallbackInfo<v8::Value>& args); + static void Evaluate(const v8::FunctionCallbackInfo<v8::Value>& args); + static void GetUrl(v8::Local<v8::String> property, + const v8::PropertyCallbackInfo<v8::Value>& info); + static void Resolve(const v8::FunctionCallbackInfo<v8::Value>& args); + static v8::MaybeLocal<v8::Module> ResolveCallback( + v8::Local<v8::Context> context, + v8::Local<v8::String> specifier, + v8::Local<v8::Module> referrer); + + v8::Persistent<v8::Module> module_; + v8::Persistent<v8::String> url_; + bool linked_ = false; + std::map<std::string, v8::Persistent<v8::Promise>*> resolve_cache_; + + static std::map<int, std::vector<ModuleWrap*>*> module_map_; +}; + +} // namespace loader +} // namespace node + +#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS + +#endif // SRC_MODULE_WRAP_H_ |