Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow removing/configuring the inputs of pnpmInstall tasks #287

Open
boris-petrov opened this issue Sep 13, 2023 · 3 comments
Open

Allow removing/configuring the inputs of pnpmInstall tasks #287

boris-petrov opened this issue Sep 13, 2023 · 3 comments

Comments

@boris-petrov
Copy link

pnpm is pretty fast. Running pnpm install generally takes a second or two when all is up-to-date even when there are many things in package.json.

On the other hand, Gradle's caches of the pnpmInstall task can take quite a while to compute if the task needs rerunning. I would like to remove that and set these tasks to always execute - i.e. depend on pnpm itself to be clever and not do anything rather than Gradle (which walks the whole node_modules to check for changes).

I definitely think this will improve the performance of my build. What do you think?

@deepy
Copy link
Member

deepy commented Sep 13, 2023

Absolutely agree, in hindsight we never should have had node_modules as an output.
If doNotTrackState had been available in Gradle when I started we likely never would've added it to outputs, but now it's there and breaking backwards compatibility pains me greatly

Good news though, there exists right now a property nodeModulesOutputFilter which lets you filter what's actually cached from node_modules

There's also this logic that's currently only implemented for npm but which I assume pnpm has something similar to

/**
* Use fast NpmInstall logic, excluding node_modules for output tracking resulting in a significantly faster
* npm install/ci configuration at the cost of slightly decreased correctness in certain circumstances.
*
* In practice this means that if you change node_modules through other means than npm install/ci
* NpmInstall tasks will continue being up-to-date, but if you're modifying node_modules through
* other tools you may have other correctness problems and surfacing them here may be preferred.
*
* https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json#hidden-lockfiles
*
* Requires npm 7 or later
* This will become the default in 4.x
*/
val fastNpmInstall = project.objects.property<Boolean>().convention(false)

With all the power of hindsight and user feedback, I believe that is the best possible solution for the general case

@boris-petrov
Copy link
Author

Why does a breaking change bother you? Just release a new major version and call it a day. 😄 That's what major versions are for. Software has to move forward.

So I could use this nodeModulesOutputFilter today for my pnpm tasks?

@deepy
Copy link
Member

deepy commented Sep 15, 2023

Yup, you can also use doNotTrackState to leave it entirely up to pnpm

As for the change, that's already happening, in likely the next major I'll flip the switch and make it the default
Ideally there'd be something similar in yarn and pnpm at that point, but I haven't had the time to investigate them (and the current yarn support is lackluster)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants