| | |
| | | |
| | | class RuntimeChunkPlugin { |
| | | /** |
| | | * Creates an instance of RuntimeChunkPlugin. |
| | | * @param {{ name?: RuntimeChunkFunction }=} options options |
| | | */ |
| | | constructor(options) { |
| | | constructor(options = {}) { |
| | | /** @type {{ name: string | RuntimeChunkFunction }} */ |
| | | this.options = { |
| | | /** @type {RuntimeChunkFunction} */ |
| | | name: (entrypoint) => `runtime~${entrypoint.name}`, |
| | | ...options |
| | | }; |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | |
| | | (compilation.entries.get(entryName)); |
| | | if (data.options.runtime === undefined && !data.options.dependOn) { |
| | | // Determine runtime chunk name |
| | | let name = |
| | | /** @type {string | RuntimeChunkFunction} */ |
| | | (this.options.name); |
| | | let name = this.options.name; |
| | | if (typeof name === "function") { |
| | | name = name({ name: entryName }); |
| | | } |