1

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

  • As you observed, some of the older versions of pact accidentally contained the `build` directory. We had actually fixed this problem, and then some. However due to an issue with npm and no real resolution to our problem, we had to revert part of that fix - so you basically have to pay for all of the potential OS's that we support. #sorry – Matthew Fellows Feb 22 '18 at 06:52
  • Cool - thanks for the reply – Shane Treacy Feb 28 '18 at 21:41

1 Answers1

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.

J_A_X
  • 12,857
  • 1
  • 25
  • 31
  • @ShaneTreacy I'm actually looking to fix the packager so that only the OS specific build is downloaded and not all of them. It should reduce the filesize a decent amount. – J_A_X Mar 01 '18 at 03:07
  • Awesome, that would be great! – Shane Treacy Mar 07 '18 at 23:20
  • @ShaneTreacy currently going through PR: https://github.com/pact-foundation/pact-node/pull/76 – J_A_X Mar 14 '18 at 06:38