This works around an issue where using Istanbul with the noop instrumenter means it will try to parse your code with a hard-coded Babel config that may not work (especially if the code it's trying to parse is TypeScript).
This kludges the problem away by using patch-package in a post-install script to patch istanbul-lib-instrument
to look for an environment variable pointing to your Babel config file, and a one-line patch to nyc
to make it pass the filename when calling the patched functions in istanbul-lib-instrment
(otherwise it will fail if your babel config includes overrides
).
To use this, setup patch-package as shown in their README, then make a patches
directory in your repo and drop these two patch files into it. Then just running yarn
(or npm install
) should be enough to do the patching. Then you just have to make sure that $ISTANBUL_BABEL_CONFIG
is set to the path to your babel confi