MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/snap.cafsinfotech.in/node_modules/laravel-mix-polyfill/index.js
const mix = require('laravel-mix');

class Polyfill {
    dependencies() {
        return ['core-js', 'regenerator-runtime'];
    }

    register(config) {
        this.config = Object.assign({
            enabled: true,
            useBuiltIns: "usage",
            targets: "defaults",
            entryPoints: "stable",
            corejs: 3,
            debug: false,
        }, config);
    }

    webpackConfig(webpackConfig) {
        if ((this.config.enabled === true)
            && (this.config.useBuiltIns === "entry")
            && (this.config.entryPoints !== false)) {
            Object.entries(webpackConfig.entry).forEach(v => {
                webpackConfig.entry[v[0]].unshift("laravel-mix-polyfill/entry/"
                    + this.config.entryPoints
                    + ".js");
            });
        }

        if ((this.config.enabled === true) && (typeof this.config.targets === "string")) {
            webpackConfig.target = 'browserslist:' + this.config.targets;
        }

        if (this.config.debug === true) {
            let javascriptIndex = null;

            webpackConfig.module.rules.forEach(function (value, index) {
                if (value['test'].toString() === '/\\.(cjs|mjs|jsx?|tsx?)$/') {
                    javascriptIndex = index;
                }
            });

            if (javascriptIndex) {
                webpackConfig.module.rules[javascriptIndex]['use'][0]['options']['cacheDirectory'] = false;
            }
        }
    }

    babelConfig() {
        let polyfillPresets = {
            "useBuiltIns": this.config.useBuiltIns,
        };

        if (this.config.useBuiltIns !== false) {
            polyfillPresets.corejs = this.config.corejs;
        }

        if (this.config.targets) {
            polyfillPresets.targets = this.config.targets;
        }

        if (this.config.debug) {
            polyfillPresets.debug = this.config.debug;
        }

        let returnObject = {
            presets: [
                [
                    '@babel/preset-env',
                    polyfillPresets
                ]
            ],
        };

        return this.config.enabled ? returnObject : {};
    }
}

mix.extend('polyfill', new Polyfill());