I like using lifecycle scripts for local development, but I don’t want third party packages to run their install scripts on my machine.
Typically my scripts look something like this:
The pretest script could be merged into the test script using the && operator. However, I think the output is nicer when npm logs each step.
The prepack script is more important. It makes sure the TypeScript project gets compiler before packing / publishing.
A good first step would be to have an option to only run local scripts, no lifecycle hooks of any dependencies. Another idea is to explicitly allowlist which dependencies are allowed to run their lifecycle hooks. In a next major this could even disallow all dependencies by default.
This is related to #8698, but takes it a step further.
{ // … "scripts": { "prepack": "tsc --build", "pretest": "tsc --build", "test": "node --test" } }