Using shake with npm to build and depend on node_modules.

20 views
Skip to first unread message

seantp...@gmail.com

unread,
Apr 19, 2018, 7:57:09 PM4/19/18
to Shake build system
Hi there.

I've been staring at Shake thinking it would solve some issues with our npm based project. But I've been baffled by how to handle the node_modules folder.

The flow should be simple from what I can tell:
- Any change to package.json would cause node_modules to be re-populated.
- All the changes to 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.

Any help would be greatly appreciated,
Sean.

Neil Mitchell

unread,
Apr 19, 2018, 11:28:11 PM4/19/18
to seantp...@gmail.com, Shake build system
Hi Sean,

Is the problem that node_modules is a directory rather than a file?
See https://shakebuild.com/faq#how-can-i-depend-on-directories - you
can solve it by creating a fake file, something along the lines of
(untested):

"node_modules/.stamp" %> \out -> do
need ["package.json"]
cmd_ "npm reload"
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.

Does that answer the question, or is there some other aspect you are
having difficulties with?

Thanks, Neil

Sean Parsons

unread,
Apr 20, 2018, 4:54:52 PM4/20/18
to Neil Mitchell, Shake build system
Amazing, that's exactly what I needed! The sentinel file like thing I just had no intuition for.

Thanks for that,
Sean.
Reply all
Reply to author
Forward
0 new messages