Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How do I compile the JS files in the modules folder? #89

Closed
neroarth94 opened this issue Apr 29, 2021 · 3 comments
Closed

Question: How do I compile the JS files in the modules folder? #89

neroarth94 opened this issue Apr 29, 2021 · 3 comments

Comments

@neroarth94
Copy link

For example, maybe I just want to change the message in the consoles from "...Installing service" to "...Installing agent service".
I tried to change the code in agent-installer.js and using Visual Studio to rebuild the agent project, but it does not take any affect at all. May I know how do I compile the project so that any changes in the .js can take effect in the next build?.
Thank you.
image

@jokrug
Copy link

jokrug commented Oct 20, 2021

I have more or less the same question.
What I already found out is, that the files in the folder modules are not directly compiled into the agent.
They appear as "compressed module" in microscript/ILibDuktape_Polyfills.c.
What I miss is the information how to compress the modules and include them into ILibDuktape_Polyfills.c.
I guess, this step has to be done manually, each time you make changes on one of the modules.

@krayon007
Copy link
Collaborator

There are two ways to do this... When debugging, and making changes, you can modify the .js file directly, and just save it in the same folder as the agent binary... The agent will use the .js file from disc if it's there, if it's newer than the one compiled in the binary. You don't even need to restart the agent. You can just clear the core, and reload the core.....

When you are satisfied with your changes to the .js file, you can use the clipboard, in the following fashion:
meshagent -exec "require('clipboard').nativeAddCompressedModule('foo');process.exit();"

if the file you modified isn't in the same folder as the agent binary, you can use the following command if you don't want to move the file, and edit it directly in the modules folder:

meshagent -exec "setModulePath('pathToFolder');require('clipboard').nativeAddCompressedModule('foo');process.exit();"
This command is just like the previous, except it searches for modules in the path specified.

Just substitute foo, with the name of the module that you modified. It will load the module from disc, compress it, and save it into the cliboard.. So you can just load up your editor for ILibDuktape_Polyfills.c, and find where that particular module is defined... and paste directly from the clipboard... The clipboard will contain all the necessary C code to uncompress and load the module.

If the compressed result is relatively long, it will auto break it up into multiple lines to work around an issue with visual studio's maximum string literal limitations.

@jokrug
Copy link

jokrug commented Oct 29, 2021

Thank you for the explanation. I'll try that out asap.
Maybe it would be a good idea to add that lines to the readme.md
They are very helpfull, but hard to find in the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants