I am using Shake with an npm based project, but am baffled by how to handle the node_modules
folder. The flow should be simple from what I can tell:
package.json
would cause node_modules
to be re-populated.node_modules
and/or main.ts
would cause a typescript related script to fire. In this case it would only run the once for the entire collection of changes.How do I encode those dependencies?
The problem is that node_modules
is a directory rather than a file, and you can't depend on directories. The solution is to create a fake file, along the lines of:
"node_modules/.stamp" %> \out -> do
need ["package.json"]
cmd_ "npm update"
copyFile' "package.json" out
"main.ts.out" %> \out -> do
need ["node_modules/.stamp","main.ts"]
cmd_ "whatever"
The only "weird" bit above is that we copyFile'
the package.json
for
our stamp file. That's a trick so that if we have hash-checking on the
files then the .stamp
file changes, whereas if we always wrote ""
to
it then it wouldn't.