抖动依赖node_modules目录

Shake depending on on node_modules directory

我在基于 npm 的项目中使用 Shake,但对如何处理 node_modules 文件夹感到困惑。据我所知,流程应该很简单:

如何对这些依赖项进行编码?

问题是node_modules是目录而不是文件,而你can't depend on directories。解决方案是按照以下行创建一个假文件:

"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"

上面唯一的 "weird" 位是我们 copyFile' package.json 我们的邮票文件。这是一个技巧,所以如果我们对 files 然后 .stamp 文件改变,而如果我们总是写 "" 到 那就不行了。