MCPcopy
hub / github.com/webpack/webpack / constructor

Method constructor

lib/Compilation.js:603–1402  ·  lib/Compilation.js::Compilation.constructor

* Creates an instance of Compilation. * @param {Compiler} compiler the compiler which created the compilation * @param {CompilationParams} params the compilation parameters

(compiler, params)

Source from the content-addressed store, hash-verified

601 * @param {CompilationParams} params the compilation parameters
602 */
603 constructor(compiler, params) {
604 /** @type {boolean} */
605 this._backCompat = compiler._backCompat;
606
607 const getNormalModuleLoader = () => deprecatedNormalModuleLoaderHook(this);
608 /** @typedef {{ additionalAssets?: boolean | ((assets: CompilationAssets) => void) }} ProcessAssetsAdditionalOptions */
609 /** @type {AsyncSeriesHook<[CompilationAssets], ProcessAssetsAdditionalOptions>} */
610 const processAssetsHook = new AsyncSeriesHook([class="st">"assets"]);
611
612 /** @type {Set<string>} */
613 let savedAssets = new Set();
614 /**
615 * Returns new assets.
616 * @param {CompilationAssets} assets assets
617 * @returns {CompilationAssets} new assets
618 */
619 const popNewAssets = (assets) => {
620 /** @type {undefined | CompilationAssets} */
621 let newAssets;
622 for (const file of Object.keys(assets)) {
623 if (savedAssets.has(file)) continue;
624 if (newAssets === undefined) {
625 newAssets = Object.create(null);
626 }
627 /** @type {CompilationAssets} */
628 (newAssets)[file] = assets[file];
629 savedAssets.add(file);
630 }
631 return /** @type {CompilationAssets} */ (newAssets);
632 };
633 processAssetsHook.intercept({
634 name: class="st">"Compilation",
635 call: () => {
636 savedAssets = new Set(Object.keys(this.assets));
637 },
638 register: (tap) => {
639 const { type, name } = tap;
640 const { fn, additionalAssets, ...remainingTap } = tap;
641 const additionalAssetsFn =
642 additionalAssets === true ? fn : additionalAssets;
643 /** @typedef {WeakSet<CompilationAssets>} ProcessedAssets */
644
645 /** @type {ProcessedAssets | undefined} */
646 const processedAssets = additionalAssetsFn ? new WeakSet() : undefined;
647 /**
648 * Gets available assets.
649 * @param {CompilationAssets} assets to be processed by additionalAssetsFn
650 * @returns {CompilationAssets} available assets
651 */
652 const getAvailableAssets = (assets) => {
653 /** @type {CompilationAssets} */
654 const availableAssets = {};
655 for (const file of Object.keys(assets)) {
656 class="cm">// https://github.com/webpack-contrib/compression-webpack-plugin/issues/390
657 if (this.assets[file]) {
658 availableAssets[file] = assets[file];
659 }
660 }

Callers

nothing calls this directly

Calls 15

getLoggerMethod · 0.95
getCacheMethod · 0.95
interceptMethod · 0.80
tapMethod · 0.80
freezeMethod · 0.80
addFileTimestampsMethod · 0.80
addContextTimestampsMethod · 0.80
keysMethod · 0.65
resolveMethod · 0.65
fnFunction · 0.50
callbackFunction · 0.50

Tested by

no test coverage detected