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/mapbox-gl/build/node-loader.js
import flowRemoveTypes from '@mapbox/flow-remove-types';
import {dataToEsm} from '@rollup/pluginutils';

const glslRe = /\.glsl$/;
const jsonRe = /\.json$/;

export async function resolve(specifier, context, nextResolve) {
    if (glslRe.test(specifier)) {
        const url = new URL(specifier, context.parentURL).href;
        return {url, shortCircuit: true};
    }

    return nextResolve(specifier);
}

export async function load(url, context, nextLoad) {
    if (context.format === 'module') {
        const {source: rawSource} = await nextLoad(url, context);
        const source = rawSource.toString();
        if (source.indexOf('@flow') >= 0) {
            const transformedSource = flowRemoveTypes(source).toString();
            return {format: 'module', source: transformedSource, shortCircuit: true};
        }
    }

    if (glslRe.test(url)) {
        const {source: rawSource} = await nextLoad(url, {...context, format: 'module'});
        const source = `export default \`${rawSource.toString()}\``;
        return {format: 'module', source, shortCircuit: true};
    }

    if (jsonRe.test(url)) {
        const {source: rawSource} = await nextLoad(url, {...context,
            // Force import assertions as "assert { type: 'json' }"
            importAssertions: {type: 'json'}
        });

        const source = dataToEsm(JSON.parse(rawSource.toString()), {
            preferConst: true,
            namedExports: true,
            indent: '    '
        });

        return {format: 'module', source, shortCircuit: true};
    }

    return nextLoad(url);
}