Reputation:
i want to compile my typescript code into js automatically, when a project require mine. For exemple when a project npm install or update my project like dependency, i want that after all the dependencies are installed, it run a specific command that will compile my TS into JS.
Thanks to it, i've not to save my compiles files into my repository or the user who require my project don't has to compile my TS into JS.
Do you have a solution ?
Thank you :)
Upvotes: 0
Views: 725
Reputation: 18193
You should setup a "post install" script to run in your npm package.
You can read about it in the npm documentation.
Basically, add the command line that you use to the "scripts" section of your package.json file. Here is an example of the "scripts" JSON from the above link:
{ "scripts" :
{ "install" : "scripts/install.js"
, "postinstall" : "scripts/install.js"
, "uninstall" : "scripts/uninstall.js"
}
}
You can replace the scripts/install.js
command with the command (or script) that compiles your code. Note that "install" and "postinstall" are the same thing, you only need to use one of them.
Upvotes: 1