<commit_before>//Load the requirejs optimizer
var requirejs = require('<%= rjs_path %>'),
  //Set up basic config, include config that is
  //common to all the optimize() calls.
  baseConfig = <%=
    modifiedHash = build_config.select {|k, _| k != "modules"}
    pathsHash = modifiedHash["paths"]
    modifiedHash["dir"] = build_dir.to_s
    modifiedHash["paths"] = pathsHash.select {|_, v| !v.is_a?(Array)} if !pathsHash.nil?

    JSON.pretty_generate(modifiedHash)
  %>;

baseConfig.modules = [
<% build_config['modules'].each do |m| %>
<%= JSON.pretty_generate(m) %>,
<% end %>
];

requirejs.optimize(baseConfig);<commit_msg>Update the `r.js` driver to handle CDN paths with the recent shift to whole-project optimization<commit_after>var requirejs = require(<%= rjs_path.to_s.dump %>)
var baseConfig = <%=
cdn_pattern = Regexp.new("\\Ahttps?://")

modifiedHash = build_config.select { |k, _| k != "modules" }
pathsHash = modifiedHash["paths"]
modifiedHash["dir"] = build_dir.to_s
modifiedHash["paths"] = Hash[pathsHash
  .select do |_, v|
    !v.is_a?(Array)
  end.map do |k, v|
    [k, if !cdn_pattern.match(v) then v else "empty:" end]
  end
] if !pathsHash.nil?

JSON.pretty_generate(modifiedHash)
%>;

baseConfig.modules = [
<% build_config["modules"].each do |m| %>
  <%= JSON.pretty_generate(m) %>,
<% end %>
];

requirejs.optimize(baseConfig);
{'fraction_non_alphanumeric': 0.17343173431734318, 'fraction_numerical': 0.0, 'mean_word_length': 4.65, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4025468', 'n_tokens_mistral': 491, 'n_tokens_neox': 466, 'n_words': 105}