<commit_before>var fs = require('fs');
var JSIO = jsio.__jsio;

var conditionalImport = /(\s*import\s+)([^=+*"',\s\r\n;\/]+\|[^=+"',\s\r\n;\/]+)(\s*[^'";=]+)/gm;

function replace(path, raw, p1, p2, p3) {
	if (!/\/\//.test(p1)) {
		var opts = p2.split('|');

		for(var i = 0; i < opts.length; i++) {
			var modules = JSIO.__util.resolveModulePath(opts[i], path);
			var found = false;
			for (var j = 0; j < modules.length; j++) {
				if (fs.existsSync(modules[j].path)) {
					found = true;
					break;
				}
			}
			if (found) {
				p2 = opts[i];
				break;
			}
		}

                return p1 + p2 + p3;
        }
        return raw;
}

exports = function (path, moduleDef, opts) {
	moduleDef.src = moduleDef.src.replace(conditionalImport, replace.bind(null, path));
}
<commit_msg>Fix conditional import path issue<commit_after>var fs = require('fs');
var util = jsio.__jsio.__util;

var conditionalImport = /(\s*import\s+)([^=+*"',\s\r\n;\/]+\|[^=+"',\s\r\n;\/]+)(\s*[^'";=]+)/gm;

function replace(path, raw, p1, p2, p3) {
	if (!/\/\//.test(p1)) {
		var opts = p2.split('|');

		for(var i = 0; i < opts.length; i++) {
			var modules = util.resolveModulePath(opts[i], path);
			var found = false;
			for (var j = 0; j < modules.length; j++) {
				if (fs.existsSync(util.buildPath(modules[j].directory, modules[j].filename))) {
					found = true;
					break;
				}
			}
			if (found) {
				p2 = opts[i];
				break;
			}
		}

                return p1 + p2 + p3;
        }
        return raw;
}

exports = function (path, moduleDef, opts) {
	moduleDef.src = moduleDef.src.replace(conditionalImport, replace.bind(null, path));
}

{'fraction_non_alphanumeric': 0.2214723926380368, 'fraction_numerical': 0.013496932515337423, 'mean_word_length': 2.6569506726457397, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2002203', 'n_tokens_mistral': 733, 'n_tokens_neox': 639, 'n_words': 135}