<commit_before>var path = require("path");
var loaderUtils = require("loader-utils");
var fs = require("fs");
var fetchComponentAssets = require("./fetch-component-assets-from-php");

module.exports = function(source, map) {

    var query = loaderUtils.parseQuery(this.query);

    if (!query.defer) {
        this.emitError("Missing loader parameter defer");
        return;
    }
    var loadDefer = query.defer == '1';

    if (!query.package) {
        this.emitError("Missing loader parameter package");
        return;
    }
    var package = query.package;

    this.cacheable();
    /*
    var callback = this.async();
    if (!callback) {
        this.emitError("Only async supported");
        return;
    }
    */

    var ret = '';
    if (!loadDefer) {
        var url = require.resolve('./component-assets-loader')+"?defer=1&package="+package+"!";
        ret += "require.ensure('"+url+"', function() { require('"+url+"'); });\n;";
    }

    var packageAssets = fetchComponentAssets();

    var cmps = packageAssets[package];
    for (var cmp in cmps) {
        var kwcClass = cmps[cmp].kwcClass;
        var kwcClassMaster = cmps[cmp].kwcClassMaster;
        cmps[cmp].files.forEach(function(asset) {
            var isMaster = !!asset.match(/Master(\.defer)?\.[a-z]+$/);
            var cls = isMaster ? kwcClassMaster : kwcClass;
            var isDeferredAsset = !!asset.match(/\.defer\.[a-z]+$/);
            if (isDeferredAsset == loadDefer) {
                if (asset.match(/\.scss$/)) {
                    ret += "require('"+require.resolve('./component-file-loader')+"?cls="+cls+"!"+require.resolve('./component-inject-class-loader')+"?cls="+cmp+"!./"+asset+"')\n";
                } else {
                    ret += "require('"+require.resolve('./component-file-loader')+"?cls="+cls+"!./"+asset+"');\n";
                }
            }
        }, this);
        var dep, files;
        if (!loadDefer) {
            dep = cmps[cmp].assets.dep;
            files = cmps[cmp].assets.files;
        } else {
            dep = cmps[cmp].assetsDefer.dep;
            files = cmps[cmp].assetsDefer.files;
        }
        dep.forEach(function(asset) {
            ret += "require('"+require.resolve('../loader//ini-loader')+"?dep="+asset+"!');\n";
        }, this);
        files.forEach(function(asset) {
            var isMaster = !!asset.match(/Master(\.defer)?\.[a-z]+$/);
            var cls = isMaster ? kwcClassMaster : kwcClass;
            ret += "require('"+require.resolve('./component-file-loader')+"?cls="+cls+"!"+require.resolve('./component-inject-class-loader')+"?cls="+cmp+"!"+asset+"');\n";
        }, this);
    }

    //callback(null, ret);
    return ret;
};<commit_msg>fix double-slash in path<commit_after>var path = require("path");
var loaderUtils = require("loader-utils");
var fs = require("fs");
var fetchComponentAssets = require("./fetch-component-assets-from-php");

module.exports = function(source, map) {

    var query = loaderUtils.parseQuery(this.query);

    if (!query.defer) {
        this.emitError("Missing loader parameter defer");
        return;
    }
    var loadDefer = query.defer == '1';

    if (!query.package) {
        this.emitError("Missing loader parameter package");
        return;
    }
    var package = query.package;

    this.cacheable();
    /*
    var callback = this.async();
    if (!callback) {
        this.emitError("Only async supported");
        return;
    }
    */

    var ret = '';
    if (!loadDefer) {
        var url = require.resolve('./component-assets-loader')+"?defer=1&package="+package+"!";
        ret += "require.ensure('"+url+"', function() { require('"+url+"'); });\n;";
    }

    var packageAssets = fetchComponentAssets();

    var cmps = packageAssets[package];
    for (var cmp in cmps) {
        var kwcClass = cmps[cmp].kwcClass;
        var kwcClassMaster = cmps[cmp].kwcClassMaster;
        cmps[cmp].files.forEach(function(asset) {
            var isMaster = !!asset.match(/Master(\.defer)?\.[a-z]+$/);
            var cls = isMaster ? kwcClassMaster : kwcClass;
            var isDeferredAsset = !!asset.match(/\.defer\.[a-z]+$/);
            if (isDeferredAsset == loadDefer) {
                if (asset.match(/\.scss$/)) {
                    ret += "require('"+require.resolve('./component-file-loader')+"?cls="+cls+"!"+require.resolve('./component-inject-class-loader')+"?cls="+cmp+"!./"+asset+"')\n";
                } else {
                    ret += "require('"+require.resolve('./component-file-loader')+"?cls="+cls+"!./"+asset+"');\n";
                }
            }
        }, this);
        var dep, files;
        if (!loadDefer) {
            dep = cmps[cmp].assets.dep;
            files = cmps[cmp].assets.files;
        } else {
            dep = cmps[cmp].assetsDefer.dep;
            files = cmps[cmp].assetsDefer.files;
        }
        dep.forEach(function(asset) {
            ret += "require('"+require.resolve('../loader/ini-loader')+"?dep="+asset+"!');\n";
        }, this);
        files.forEach(function(asset) {
            var isMaster = !!asset.match(/Master(\.defer)?\.[a-z]+$/);
            var cls = isMaster ? kwcClassMaster : kwcClass;
            ret += "require('"+require.resolve('./component-file-loader')+"?cls="+cls+"!"+require.resolve('./component-inject-class-loader')+"?cls="+cmp+"!"+asset+"');\n";
        }, this);
    }

    //callback(null, ret);
    return ret;
};
{'fraction_non_alphanumeric': 0.19669117647058823, 'fraction_numerical': 0.0007352941176470588, 'mean_word_length': 2.321733821733822, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4740534', 'n_tokens_mistral': 1674, 'n_tokens_neox': 1655, 'n_words': 273}