为什么我们应该将watchify参数传递给browserify?

9

watchify 的文档中,我了解到:

When creating the browserify instance b you MUST set these properties in the constructor:

var b = browserify({ cache: {}, packageCache: {}, fullPaths: true })

这 3 个参数 cache: {}, packageCache: {}, fullPaths: true 是为了 watchify,但为什么我们要将它们传递给 browserify 而不是传递给 watchify 呢?

1个回答

2
它们被传递给 browserify,因为 cachepackageCache 选项被转发到 module-deps
这里有作者的一条评论 here

缓存选项被转发到 module-deps:https://github.com/substack/module-deps/blob/master/index.js

cache 的内容在 module-deps 中没有被修改,因此它被传递可能是出于性能考虑。然而,packageCache 的内容被修改了,所以似乎存在着 module-depswatchify 之间通过共享的 packageCache 进行交互的情况。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接