Node.js API compatibility - Module
The module
API in Node.js is a built-in module that provides functionalities for working with JavaScript modules. It’s essential for managing the modular structure of Node.js applications, allowing developers to organize code into reusable components.
/** * An example of using the Node.js Module API in an Azion Edge Function. * Support: * - Partially supported * @module runtime-apis/nodejs/module/main * @example * // Execute with Azion Bundler: * npx edge-functions build * npx edge-functions dev */import module from "node:module";
/** * An example of using the Node.js Module API in an Azion Edge Function. * @param {*} event * @returns {Promise<Response>} */const main = async (event) => { return new Promise((resolve, reject) => { module.builtinModules.forEach((moduleName) => { console.log(moduleName); }); resolve(new Response("Done")); });};
export default main;
Contributors