File
Blob: src/workerd/api/node/module.h
| 1 | // Copyright (c) 2017-2022 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | #pragma once |
| 5 | |
| 6 | #include <workerd/jsg/jsg.h> |
| 7 | |
| 8 | namespace workerd::api::node { |
| 9 | |
| 10 | class ModuleUtil final: public jsg::Object { |
| 11 | public: |
| 12 | ModuleUtil() = default; |
| 13 | ModuleUtil(jsg::Lock&, const jsg::Url&) {} |
| 14 | |
| 15 | jsg::JsValue createRequire(jsg::Lock& js, kj::String specifier); |
| 16 | |
| 17 | // Returns true if the specifier is a known node.js built-in module specifier. |
| 18 | // Ignores whether or not the module actually exists (use process.getBuiltinModule() |
| 19 | // for that purpose). |
| 20 | bool isBuiltin(kj::String specifier); |
| 21 | |
| 22 | JSG_RESOURCE_TYPE(ModuleUtil) { |
| 23 | JSG_METHOD(createRequire); |
| 24 | JSG_METHOD(isBuiltin); |
| 25 | } |
| 26 | }; |
| 27 | |
| 28 | #define EW_NODE_MODULE_ISOLATE_TYPES api::node::ModuleUtil |
| 29 | |
| 30 | } // namespace workerd::api::node |