This isn't an issue with patch-package specifically, but I wanted to share it here nonetheless to help anyone else who might run into this.
When using Heroku's Node buildpack, by default the following will happen during the build and startup process:
- install all dependencies (including
devDependencies) with yarn --production="false"
- run build step
- prune dev dependencies with
yarn --production="true"
- run the app
However, at step 3 when the dev dependencies are pruned, the buildpack also specifies the --ignore-scripts flag when calling yarn (since v119). This means patch-package will not run, because the postinstall/prepare scripts will not be ran. In turn, this means when the app runs, Node modules will not be patched (!).
The only workaround I'm aware of at the moment is to disable pruning of dev dependencies with YARN_PRODUCTION=false.
I can semi-understand why the buildpack would want to avoid invoking scripts, since the scripts were already run after step 1. In any case I've raised an issue with the buildpack to investigate what changes we can make there: heroku/heroku-buildpack-nodejs#634
This isn't an issue with
patch-packagespecifically, but I wanted to share it here nonetheless to help anyone else who might run into this.When using Heroku's Node buildpack, by default the following will happen during the build and startup process:
devDependencies) withyarn --production="false"yarn --production="true"However, at step 3 when the dev dependencies are pruned, the buildpack also specifies the
--ignore-scriptsflag when callingyarn(since v119). This meanspatch-packagewill not run, because thepostinstall/preparescripts will not be ran. In turn, this means when the app runs, Node modules will not be patched (!).The only workaround I'm aware of at the moment is to disable pruning of dev dependencies with
YARN_PRODUCTION=false.I can semi-understand why the buildpack would want to avoid invoking scripts, since the scripts were already run after step 1. In any case I've raised an issue with the buildpack to investigate what changes we can make there: heroku/heroku-buildpack-nodejs#634