I am wondering, how can I read variables names, classes names, and other stuff in .mjs file using Node.js.
I have for example file:
class AppRequestResult {
constructor() {
this.test = new TestRequests();
this.subject = new SubjectRequests();
this.question = new QuestionRequests();
}
}
function abc() { return 2; }
function def() { return abc(); }
const text = "sometext";
export const AppRequest = new AppRequestResult();
export const ApiUrl = `localhost/app`;
And how to retrieve:
Variables:
- text
- AppRequest (mark it as exported in result)
- ApiUrl (mark it as exported in result)
Classes:
- AppRequestResult
Functions:
- abc
- def (mark it as exported in result)
I tried to search for packages in Node.js that could do that, but I found none. Also I tried to use "import()" function in Node.js but it only displays exported things. My target is to combine all .mjs source files to one file and to do that I have to find a way to rename certain variables that are in the .mjs files and rename it to prevent "Already defined" error.