1

我们已经使用 pact 为我们的 Angular JS 前端和 java 后端实现了合同测试。

我注意到 node_modules/@pact-foundation 目录非常大(pact-node v 4.3.2)

du -sh node_modules/@pact-foundation/
741M    node_modules/@pact-foundation/

JS UI 始终只是消费者,但依赖项似乎需要以下内容

ls node_modules/@pact-foundation/
pact-mock-service            pact-node               pact-provider-verifier-linux-x64
pact-mock-service-linux-x64  pact-provider-verifier

有没有办法引入一组较小的依赖项?

编辑 - 似乎原因如下

du -sh pact-node/node_modules/@pact-foundation/pact-mock-service/build/*
1.9M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock_service-0.8.2
8.9M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-0.8.2-1-linux-x86_64.tar.gz
8.5M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-0.8.2-1-linux-x86.tar.gz
9.2M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-0.8.2-1-osx.tar.gz
12M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-0.8.2-1-win32.zip
50M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-darwin
48M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-linux-ia32
50M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-linux-x64
51M    pact-node/node_modules/@pact-foundation/pact-mock-service/build/pact-mock-service-win32

pact-node 依赖于 pact-mock-service 并且捆绑的依赖项包括所有操作系统的模拟服务。

编辑 2 -

将我的依赖项更改为以下

"@pact-foundation/pact-node": "6.9.0",    

并添加一个分辨率(我使用的是纱线而不是 npm)

"resolutions": {
  "@pact-foundation/pact-node": "6.9.0"
}

将依赖项的总大小降低到

du -sh node_modules/@pact-foundation/*
1.7M    node_modules/@pact-foundation/pact-node
170M    node_modules/@pact-foundation/pact-standalone

干杯谢恩

4

1 回答 1

0

Sadly, no, not yet.

Currently, our main Pact application is written in Ruby and is packaged with Travelling Ruby, a way to package ruby apps for different OS/architectures. Now originally, the intention was to only download the OS/arch specific binary so you don't have to load everything, however, a bug in npm is causing issues with optional dependencies when a package-lock.json is committed into a repository. To work around this issue, we ended up having to package them all together, which I particularly don't like.

However, the good news is that we are working on this problem. We are currently trying to reimplement our Pact application using Rust, which will compile down to native binaries without all the extra stuff that came with Ruby, which will reduce the overall size of the binary drastically. It isn't finalized just yet, but it is still being worked on, so please be patient.

Thanks.

于 2018-02-22T01:41:57.750 回答