Skip to content

Instantly share code, notes, and snippets.

@livingston
Created January 11, 2022 20:00
Show Gist options
  • Save livingston/0338e4db8dae577e9ab8e4c2e620bc2e to your computer and use it in GitHub Desktop.
Save livingston/0338e4db8dae577e9ab8e4c2e620bc2e to your computer and use it in GitHub Desktop.

Yarn Plugin Hooks

Hook Description
registerPackageExtensions Called when the package extensions are setup
setupScriptEnvironment Called before a script is executed
wrapScriptExecution Called as a script is getting executed
wrapNetworkRequest Called when a network request is being made
globalHashGeneration Called before the build, to compute a global hash key that we will use to detect whether packages must be rebuilt (typically when the Node version changes)
reduceDependency Called during the resolution, once for each resolved package and each of their dependencies
afterAllInstalled Called after the install method from the Project class successfully completed
validateProject Called during the Validation step of the install method from the Project class
validateWorkspace Called during the Validation step of the install method from the Project class by the validateProject hook.
populateYarnPaths Used to notify the core of all the potential artifacts of the available linkers
cleanGlobalArtifacts Called when the user requests to clean the global cache. Plugins should use this hook to remove their own global artifacts.

Source: https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-core/sources/Plugin.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment