| | |
| | | /** @typedef {import("./WebpackError")} WebpackError */ |
| | | |
| | | /** |
| | | * Cache validation token whose string representation identifies the build |
| | | * inputs associated with a cached value. |
| | | * @typedef {object} Etag |
| | | * @property {() => string} toString |
| | | */ |
| | | |
| | | /** |
| | | * Completion callback used by cache operations that either fail with a |
| | | * `WebpackError` or resolve with a typed result. |
| | | * @template T |
| | | * @callback CallbackCache |
| | | * @param {WebpackError | null} err |
| | |
| | | /** @typedef {EXPECTED_ANY} Data */ |
| | | |
| | | /** |
| | | * Handler invoked after a cache read succeeds so additional cache layers can |
| | | * react to the retrieved value. |
| | | * @template T |
| | | * @callback GotHandler |
| | | * @param {T} result |
| | |
| | | */ |
| | | |
| | | /** |
| | | * Creates a callback wrapper that waits for a fixed number of completions and |
| | | * forwards the first error immediately. |
| | | * @param {number} times times |
| | | * @param {(err?: Error | null) => void} callback callback |
| | | * @returns {(err?: Error | null) => void} callback |
| | |
| | | } |
| | | }; |
| | | |
| | | /** |
| | | * Abstract cache interface backed by tapable hooks for reading, writing, idle |
| | | * transitions, and shutdown across webpack cache implementations. |
| | | */ |
| | | class Cache { |
| | | /** |
| | | * Initializes the cache lifecycle hooks implemented by cache backends. |
| | | */ |
| | | constructor() { |
| | | this.hooks = { |
| | | /** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler<EXPECTED_ANY>[]], Data>} */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves a cached value and lets registered `gotHandlers` observe the |
| | | * result before the caller receives it. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * Stores a cache entry for the identifier and etag through the registered |
| | | * cache backend hooks. |
| | | * @template T |
| | | * @param {string} identifier the cache identifier |
| | | * @param {Etag | null} etag the etag |
| | |
| | | } |
| | | |
| | | /** |
| | | * After this method has succeeded the cache can only be restored when build dependencies are |
| | | * Persists the set of build dependencies required to determine whether the |
| | | * cache can be restored in a future compilation. |
| | | * @param {Iterable<string>} dependencies list of all build dependencies |
| | | * @param {CallbackCache<void>} callback signals when the dependencies are stored |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Signals that webpack is entering an idle phase and cache backends may flush |
| | | * or compact pending work. |
| | | * @returns {void} |
| | | */ |
| | | beginIdle() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Signals that webpack is leaving the idle phase and waits for cache |
| | | * backends to finish any asynchronous resume work. |
| | | * @param {CallbackCache<void>} callback signals when the call finishes |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Shuts down every registered cache backend and waits for cleanup to finish. |
| | | * @param {CallbackCache<void>} callback signals when the call finishes |
| | | * @returns {void} |
| | | */ |