Pact-node dependencies are very large, any way to reduce the size?

349 views Asked by At

We have implemented contract testing using pact for our Angular JS frontends and java backends.

I've noticed that the node_modules/@pact-foundation directory is pretty huge (pact-node v 4.3.2)

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

The JS UIs are always only consumers but the dependencies seem to require the following

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

Is there any way to pull in a smaller set of dependencies?

Edit - it seems the reason for this is as follows

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 depends on pact-mock-service & the bundled dependency includes the mock service for all OSes.

Edit 2 -

Changing my dependency to the following

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

and adding a resolution (I'm using yarn not npm)

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

Brings the total size of the dependencies down to

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

Cheers Shane

1

There are 1 answers

3
J_A_X On BEST ANSWER

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.