<commit_before>var transpile = require('transpile');
var nodeDependencyMap = require("../node/dependency_map"),
	minify = require("../buildTypes/minifyJS"),
	transformActiveSource = require("../node/transform_active_source"),
	_ = require("lodash");


var transpileNode = function(node, outputFormat, options, graph){
	
	
	if( !node.load.metadata.buildType || node.load.metadata.buildType === "js"  ) {
		
		transformActiveSource(node,"format-"+outputFormat,function(node, source){
			var opts = _.clone(options);
			var depMap = nodeDependencyMap(node);
			
			if(opts.useNormalizedDependencies) {
				opts.normalizeMap = depMap;
			}
			// make sure load has activeSource
			var load = _.clone(node.load, true);
			load.source = source || load.source;
			// Minify globals prior to transpiling because they can't
			// be minified after they become a System.define.
			if(load.metadata.format === "global" && options.minify) {
				load.source = minify(load.source, options);
			}
			// I'm not sure how to handle defined.  "less" is an example of something we
			// define.  Presumably these should all be ignored.
			// also ignore any non js build type ... for now ...!
			var buildType = load.metadata.buildType || "js";
			if(load.metadata.format === "defined" || buildType !== "js") {
				return source;
			}
			if(opts.normalize) {
				
				var givenNormalize = opts.normalize;
				opts.normalize = function(name, curName){
					var normalizedName = options.useNormalizedDependencies ? name : depMap[name];
					var depLoad = graph[ normalizedName ].load;
					return givenNormalize.call(this, name, depLoad, curName, load);
				};
			}
			return transpile.to(load, outputFormat, opts);
		});
	}
};

// fullGraph - if graph is a bundle ... fullGraph is the actual graph
module.exports = function(graph, outputFormat, options, fullGraph){
	
	options = options || {};
	if(Array.isArray(graph)) {<commit_msg>handles normalizing the current load better<commit_after>var transpile = require('transpile');
var nodeDependencyMap = require("../node/dependency_map"),
	minify = require("../buildTypes/minifyJS"),
	transformActiveSource = require("../node/transform_active_source"),
	_ = require("lodash");


var transpileNode = function(node, outputFormat, options, graph){
	
	
	if( !node.load.metadata.buildType || node.load.metadata.buildType === "js"  ) {
		
		transformActiveSource(node,"format-"+outputFormat,function(node, source){
			var opts = _.clone(options);
			var depMap = nodeDependencyMap(node);
			
			if(opts.useNormalizedDependencies) {
				opts.normalizeMap = depMap;
			}
			// make sure load has activeSource
			var load = _.clone(node.load, true);
			load.source = source || load.source;
			// Minify globals prior to transpiling because they can't
			// be minified after they become a System.define.
			if(load.metadata.format === "global" && options.minify) {
				load.source = minify(load.source, options);
			}
			// I'm not sure how to handle defined.  "less" is an example of something we
			// define.  Presumably these should all be ignored.
			// also ignore any non js build type ... for now ...!
			var buildType = load.metadata.buildType || "js";
			if(load.metadata.format === "defined" || buildType !== "js") {
				return source;
			}
			if(opts.normalize) {
				
				var givenNormalize = opts.normalize;
				opts.normalize = function(name, curName){
					// if name === curName ... it's asking to normalize the current module's name
					// for something like define('component/component',[...])
					// component/component won't be in depMap.
					var depLoad;
					if(name === curName) {
						depLoad = load;
					} else {
						var normalizedName = options.useNormalizedDependencies ? name : depMap[name];
						depLoad = graph[ normalizedName ].load;
					}
					return givenNormalize.call(this, name, depLoad, curName, load);
				};
			}
			return transpile.to(load, outputFormat, opts);
		});
	}
};

// fullGraph - if graph is a bundle ... fullGraph is the actual graph
module.exports = function(graph, outputFormat, options, fullGraph){
	
	options = options || {};
	if(Array.isArray(graph)) {
{'fraction_non_alphanumeric': 0.1353637901861252, 'fraction_numerical': 0.0, 'mean_word_length': 3.435155412647374, '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': '6236870', 'n_tokens_mistral': 1448, 'n_tokens_neox': 1212, 'n_words': 333}