-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
Improve inputs/outputs on NpmInstall tasks #157
Comments
When it comes to Now if my memory serves we opted for having this as an output to prevent |
Thanks for the insights, @deepy .
If you run It's tricky given the various behaviours of the underlying npm install command. |
Is that still true if (which isn't necessarily the use-case we want to optimise for) |
My understanding is that whenever you modify package.json, it always implicitly updates the package-lock.json. |
I'm aware of the following scenarios with
The three scenarios above show that with Gradle's input/output annotations you cannot properly model all scenarios. After discussion with one of our build caching experts, we believe it is best to drop the inputs and outputs annotations on the NpmInstall task alltogether and to always run the task, and let npm decide what to run and what to avoid to run. Marking the node_modules directory as an output is also problematic. This directory can be very, very big, leading to (performance) overhead when Gradle has to calculate the hash of the node_modules folder and when copying in and out the content of the node_modules folder. At the same time, npm itself is already doing basically the same in terms of file I/O by copying over the needed modules from a local cache. Thus, there is not much to gain by using Gradle's caching functionality on top of npm's caching. The latest npm version even has a package-lock.json in the node_modules folder to speed up calculating the state of the node_modules folder. This behavior cannot be mimicked in Gradle. When one build tool (Gradle) calls another build tool (npm), we feel it is best not to have the invoking build tool duplicate the optimizations that are present in the invoked build tool. The mimicking of the optimization logic might not be fully correct in all cases and as the underlying build tool evolves it will become increasingly hard/impossible for the invoking build tool to provide the same optimzation logic. Also, even if one could fully correctly duplicate the optimization logic in the invoking build tool there is very likely no performance gain compared to what the underlying build tool achieves given the highly dominating I/O operations. |
Might be able to use new feature in Gradle 7.3 to just disable state tracking for task.
|
Gradle 7.3 has been released and talks about npm specifically as something that would benefit from the https://docs.gradle.org/7.3/userguide/more_about_tasks.html#sec:untracked_external_tool |
Opting out of tracking requires 7.3 and that requires groovy 3 which requires spock 2.0 which breaks (see #207) So I'm moving this to 3.3 |
@deepy Did you have an issue upgrading to 7.3? I don't recall having to do anything special to upgrade and have been using the |
@nickcaballero 7.3 upgrade was smooth but required upgrading to groovy 3 and that meant upgrading spock to 2.0 (from 1.3) which broke the So no issues with Gradle, but our test suite broke with the spock upgrade |
From the npm docs:
https://docs.npmjs.com/cli/v7/commands/npm-install#description
In practice, this means that when running
npm install
and, for example, a package-lock.json is present, that package lock file will serve as an input and not as an output.The text was updated successfully, but these errors were encountered: