* Merges additional options into the chunk group. * Order-based options are combined by taking the higher priority, while * unsupported conflicts surface as an explicit error. * @param {ChunkGroupOptions} options the chunkGroup options passed to addOptions * @returns {void}
(options)
| 132 | * @returns {void} |
| 133 | */ |
| 134 | addOptions(options) { |
| 135 | for (const key of /** @type {(keyof ChunkGroupOptions)[]} */ ( |
| 136 | Object.keys(options) |
| 137 | )) { |
| 138 | if (this.options[key] === undefined) { |
| 139 | /** @type {ChunkGroupOptions[keyof ChunkGroupOptions]} */ |
| 140 | (this.options[key]) = options[key]; |
| 141 | } else if (this.options[key] !== options[key]) { |
| 142 | if (key.endsWith("Order")) { |
| 143 | const orderKey = |
| 144 | /** @type {Exclude<keyof ChunkGroupOptions, "name" | "fetchPriority">} */ |
| 145 | (key); |
| 146 | |
| 147 | this.options[orderKey] = Math.max( |
| 148 | /** @type {number} */ |
| 149 | (this.options[orderKey]), |
| 150 | /** @type {number} */ |
| 151 | (options[orderKey]) |
| 152 | ); |
| 153 | } else { |
| 154 | throw new Error( |
| 155 | `ChunkGroup.addOptions: No option merge strategy for ${key}` |
| 156 | ); |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Returns the configured name of the chunk group, if one was assigned. |