feat: support multiple retry rules #21
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for multiple retry rules in the
Assets Retry
plugin, enabling more granular control over retry strategies for different asset types or domains. Key changes include updates to the plugin's configuration structure, runtime logic, and documentation in both English and Chinese.Configuration Updates:
AssetsRetryOptions
Type: Added support for specifying multiple retry rules via therules
property, along with options forinlineScript
andminify
. This allows users to define retry strategies tailored to specific assets or domains. (README.md
: [1]README.zh-CN.md
: [2]PluginAssetsRetryOptions
type to accommodate single or multiple retry rules. Introduced logic inpluginAssetsRetry
to handle both modes. (src/types.ts
: [1]src/index.ts
: [2] [3]Runtime Logic Enhancements:
findMatchingConfig
function to identify the appropriate retry rule based on asset URLs. This function is used across runtime modules for dynamic rule evaluation. (src/runtime/asyncChunkRetry.ts
: [1] [2] [3];src/runtime/initialChunkRetry.ts
: [4] [5] [6]initRetry
,nextRetry
, andensureChunk
functions to incorporate rule-based retry logic, ensuring compatibility with both single and multiple configurations. (src/runtime/asyncChunkRetry.ts
: [1] [2] [3]Documentation Updates:
rules
property, illustrating use cases for different asset types and CDNs. (README.md
: README.mdR332-R401)README.zh-CN.md
: README.zh-CN.mdR330-R399)Code Refactoring:
src/runtime/asyncChunkRetry.ts
: [1] [2];src/runtime/initialChunkRetry.ts
: [3]These changes collectively enhance the flexibility and robustness of the
Assets Retry
plugin, making it easier to handle diverse retry requirements in complex asset loading scenarios.