resolver/resolve-fix.js
function fixFiles() {
		logger.trace("inside fixFiles()");
		_.each(registry.files, function(file) {
			var fullpath = path.join(rootpath, file);
			var basepath = path.posix.dirname(file);
			var basefile = path.posix.resolve(file);
			var source = fs.readFileSync(fullpath, 'utf8');
			logger.trace("fixing file: " + fullpath);
			var requireRegex = /(require)\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/g;
			var staticRequireRegex = /(require)(?:\(\s*['"])([^'"]+)(?:['"]\s*\))/g;

			source = source.replace(requireRegex, function($1, $2, $3) {
				var requestedModule = $2;
				if(staticRequireRegex.test($1)) {
					var staticRequireSource = $1;
					staticRequireSource = staticRequireSource.replace(staticRequireRegex, function($1, $2, $3) {
						var resolved_path = resolver.resolve($3, basepath);
						return 'require("' + resolved_path + '")';
					});
					return staticRequireSource;
				} else {
					return 'require(Alloy.resolve(' + $3 + ', "' + basepath + '"))';
				}
			});

			fs.writeFileSync(fullpath, source, { mode: 0o755 });
		});
	}
function fixFiles() {
		logger.trace("inside fixFiles()");
		_.each(registry.files, function(file) {
			var fullpath = path.join(rootpath, file);
			var basepath = path.posix.dirname(file);
			var basefile = path.posix.resolve(file);
			var source = fs.readFileSync(fullpath, 'utf8');
			logger.trace("fixing file: " + fullpath);
			var requireRegex = /(require)\s*\(((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*)\)/g;
			var staticRequireRegex = /(require)(?:\(\s*['"])([^'"]+)(?:['"]\s*\))/g;

			source = source.replace(requireRegex, function($1, $2, $3) {
				var requestedModule = $2;
				if(staticRequireRegex.test($1)) {
					var staticRequireSource = $1;
					staticRequireSource = staticRequireSource.replace(staticRequireRegex, function($1, $2, $3) {
						var resolved_path = resolver.resolve($3, basepath);
						return 'require("' + resolved_path + '")';
					});
					return staticRequireSource;
				} else {
					return 'require(Alloy.resolve(' + $3 + ', "' + basepath + '"))';
				}
			});

			fs.writeFileSync(fullpath, source, { mode: 0o755 });
		});
	}
Fix module resolution in all found javascript files