| | |
| | | /** @typedef {import("./RequestShortener")} RequestShortener */ |
| | | |
| | | /** |
| | | * Join iterable with comma. |
| | | * @template T |
| | | * @param {Iterable<T>} iterable iterable |
| | | * @returns {string} joined with comma |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Print exports info to source. |
| | | * @param {ConcatSource} source output |
| | | * @param {string} indent spacing |
| | | * @param {ExportsInfo} exportsInfo data |
| | |
| | | let alreadyPrintedExports = 0; |
| | | |
| | | // determine exports to print |
| | | /** @type {ExportInfo[]} */ |
| | | const printedExports = []; |
| | | for (const exportInfo of exportsInfo.orderedExports) { |
| | | if (!alreadyPrinted.has(exportInfo)) { |
| | |
| | | } |
| | | }; |
| | | |
| | | /** @type {WeakMap<RequestShortener, WeakMap<Module, { header: RawSource | undefined, full: WeakMap<Source, CachedSource> }>>} */ |
| | | /** @typedef {{ header: RawSource | undefined, full: WeakMap<Source, CachedSource> }} CacheEntry */ |
| | | /** @type {WeakMap<RequestShortener, WeakMap<Module, CacheEntry>>} */ |
| | | const caches = new WeakMap(); |
| | | |
| | | const PLUGIN_NAME = "ModuleInfoHeaderPlugin"; |
| | | |
| | | class ModuleInfoHeaderPlugin { |
| | | /** |
| | | * Creates an instance of ModuleInfoHeaderPlugin. |
| | | * @param {boolean=} verbose add more information like exports, runtime requirements and bailouts |
| | | */ |
| | | constructor(verbose = true) { |
| | | /** @type {boolean} */ |
| | | this._verbose = verbose; |
| | | } |
| | | |
| | | /** |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler |
| | | * @returns {void} |
| | | */ |
| | |
| | | { chunk, chunkGraph, moduleGraph, runtimeTemplate } |
| | | ) => { |
| | | const { requestShortener } = runtimeTemplate; |
| | | /** @type {undefined | CacheEntry} */ |
| | | let cacheEntry; |
| | | let cache = caches.get(requestShortener); |
| | | if (cache === undefined) { |
| | |
| | | PLUGIN_NAME, |
| | | (moduleSource, module, { runtimeTemplate }) => { |
| | | const { requestShortener } = runtimeTemplate; |
| | | /** @type {undefined | CacheEntry} */ |
| | | let cacheEntry; |
| | | let cache = caches.get(requestShortener); |
| | | if (cache === undefined) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the header. |
| | | * @param {Module} module the module |
| | | * @param {RequestShortener} requestShortener request shortener |
| | | * @returns {RawSource} the header |