I'm working with a project that exports some functions from an exports.js
file.
// some-project/exports.js
export { loginFunction } from "./login/function"
export { registerFunction } from "./register/function"
I want to develop a tool that can import such a file and output the filesystem paths of all its exports. For example,
const projectExports = require("some-project/exports")
const exportPaths = findExportPaths(projectExports)
console.log(exportPaths) // ["/Projects/some-project/login/function.js", "/Projects/some-project/register/function.js"]
How can I implement the functionality of findExportPaths
?
I have tried the following methods/tools to accomplish this, but could not make them work:
Node js module how to get list of exported functions
This gives me a list of all the exports, not their paths
-
This method suggests using
require.resolve()
, but that gives me the path of the module I'm importing. It does not provide paths of the exports of that module. -
I can't get it to provide paths of the exports of a file.
Any help would be greatly appreciated.