exports_ignore.js

/**
 * @file exports/ignore.js
 * @copyright @spmhome @_2025
 * @author Scott Meesseman @spmeesseman
 *
 * @see {@link [webpack.js.org/experiments](https://webpack.js.org/configuration/ignorewarnings)}
 *
 *//** */

const WpwWebpackExport = require("./base");


/**
 * @augments WpwWebpackExport
 */
class WpwIgnoreExport extends WpwWebpackExport
{
    /**
     * @param {WpwExportOptions} options Plugin options
     */
    constructor(options) { super(options); }


    /**
     * @override
     */
    static create = WpwIgnoreExport.wrap.bind(this);


    /**
     * @override
     */
    create()
    {

        if (this.build.options.ignore?.enabled && this.build.options.ignore.warnings)
        {
            this.build.wpc.ignoreWarnings = [
                /Critical dependency: the request of a dependency is an expression/ // [^]*?cosmiconfig/
               // /Critical dependency: require function is used in a way in which dependencies cannot be statically extracted/,
              //  /require\.extensions is not supported by webpack\. Use a loader instead/
            ];
            this.build.logger.write("set default warning messages to be ignored:", 1);
            this.build.wpc.ignoreWarnings.forEach((w, i) => this.build.logger.write(`   [${i + 1}] "italic(${w})"`, 1));
            // /Cannot find module \'[a-z\-]+\' or its corresponding type declarations/
            //
            // stats.warningsFilter is deprecated in Wp5 in favor of wpc.ignoreWarnings, leaving for reference:s
            //
            // build.wpc.stats.warningsFilter = [
            // 	/Critical dependency\: the request of a dependency is an expression/,
            // 	/Critical dependency\: require function is used
            //                 in a way in which dependencies cannot be statically extracted/
            // ;
        }
    }
}


module.exports = WpwIgnoreExport.create;