| | |
| | | /** @typedef {import("../Compiler")} Compiler */ |
| | | |
| | | /** |
| | | * Defines the named chunk ids plugin options type used by this module. |
| | | * @typedef {object} NamedChunkIdsPluginOptions |
| | | * @property {string=} context context |
| | | * @property {string=} delimiter delimiter |
| | |
| | | |
| | | class NamedChunkIdsPlugin { |
| | | /** |
| | | * Creates an instance of NamedChunkIdsPlugin. |
| | | * @param {NamedChunkIdsPluginOptions=} options options |
| | | */ |
| | | constructor(options) { |
| | | this.delimiter = (options && options.delimiter) || "-"; |
| | | this.context = options && options.context; |
| | | constructor(options = {}) { |
| | | /** @type {NamedChunkIdsPluginOptions} */ |
| | | this.options = options; |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | |
| | | const hashFunction = compilation.outputOptions.hashFunction; |
| | | compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => { |
| | | const chunkGraph = compilation.chunkGraph; |
| | | const context = this.context ? this.context : compiler.context; |
| | | const delimiter = this.delimiter; |
| | | const context = this.options.context |
| | | ? this.options.context |
| | | : compiler.context; |
| | | const delimiter = this.options.delimiter || "-"; |
| | | |
| | | const unnamedChunks = assignNames( |
| | | [...chunks].filter((chunk) => { |