<commit_before>var _ = require('lodash'),
    Path = require('path'),
    AssetGraph = require('../'),
    uglifyJs = AssetGraph.JavaScript.uglifyJs,
    uglifyAst = AssetGraph.JavaScript.uglifyAst,
    requireJsRelationTypes = ['JavaScriptAmdRequire', 'JavaScriptAmdDefine', 'JavaScriptShimRequire', 'JavaScriptRequireJsCommonJsCompatibilityRequire'];

module.exports = function (queryObj) {
    return function flattenRequireJs(assetGraph) {
        var requireJsConfig = assetGraph.requireJsConfig;
        if (!requireJsConfig) {
            throw new Error('transforms.flattenRequireJs: No assetGraph.requireJsConfig found, please run transforms.registerRequireJsConfig first');
        }
        assetGraph.findAssets(_.extend({type: 'Html'}, queryObj)).forEach(function (htmlAsset) {
            var existingHtmlStyleRelations = assetGraph.findRelations({type: 'HtmlStyle', from: htmlAsset}, true), // includeUnpopulated
                htmlStyleInsertionPoint;
            if (existingHtmlStyleRelations.length > 0) {
                htmlStyleInsertionPoint = existingHtmlStyleRelations[existingHtmlStyleRelations.length - 1];
            }

            assetGraph.findRelations({from: htmlAsset, type: ['HtmlRequireJsMain', 'HtmlScript']}).forEach(function (startRelation) {

                // Don't do anything for regular scripts that don't use require:
                if (startRelation.type === 'HtmlScript' && assetGraph.findRelations({from: startRelation.to, type: requireJsRelationTypes}).length === 0) {
                    return;
                }
<commit_msg>Be more forgiving of missing requireJsConfig in transforms/flattenRequireJs. Emit warning instead of throwing<commit_after>var _ = require('lodash'),
    Path = require('path'),
    AssetGraph = require('../'),
    uglifyJs = AssetGraph.JavaScript.uglifyJs,
    uglifyAst = AssetGraph.JavaScript.uglifyAst,
    requireJsRelationTypes = ['JavaScriptAmdRequire', 'JavaScriptAmdDefine', 'JavaScriptShimRequire', 'JavaScriptRequireJsCommonJsCompatibilityRequire'];

module.exports = function (queryObj) {
    return function flattenRequireJs(assetGraph) {
        var requireJsConfig = assetGraph.requireJsConfig;
        if (!requireJsConfig) {
            assetGraph.emit('warn', new Error('transforms.flattenRequireJs: No assetGraph.requireJsConfig found, please run transforms.registerRequireJsConfig first'));
            return;
        }
        assetGraph.findAssets(_.extend({type: 'Html'}, queryObj)).forEach(function (htmlAsset) {
            var existingHtmlStyleRelations = assetGraph.findRelations({type: 'HtmlStyle', from: htmlAsset}, true), // includeUnpopulated
                htmlStyleInsertionPoint;
            if (existingHtmlStyleRelations.length > 0) {
                htmlStyleInsertionPoint = existingHtmlStyleRelations[existingHtmlStyleRelations.length - 1];
            }

            assetGraph.findRelations({from: htmlAsset, type: ['HtmlRequireJsMain', 'HtmlScript']}).forEach(function (startRelation) {

                // Don't do anything for regular scripts that don't use require:
                if (startRelation.type === 'HtmlScript' && assetGraph.findRelations({from: startRelation.to, type: requireJsRelationTypes}).length === 0) {
                    return;
                }

{'fraction_non_alphanumeric': 0.10531107738998483, 'fraction_numerical': 0.0018209408194233688, 'mean_word_length': 3.44804318488529, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2628583', 'n_tokens_mistral': 892, 'n_tokens_neox': 822, 'n_words': 173}