//     requirish
//     Copyright 2014 Enrico Stara 'enrico.stara@gmail.com'
//     Released under the MIT License
//     https://github.com/enricostara/require-mainify

// Import dependencies
var path = require('path');
var through = require('through2');
var resolve = require('resolve');

// The require('...') regular expression
var requireRegExp = /require\s*\(\s*(["'])(.*?)\1\s*\)\s*/g;

// The transform function
module.exports = function (file) {
    var fileFolder = path.dirname(file);
    var relativeToRoot = path.relative(fileFolder, '.');

    return through(function (buf, enc, next) {
        this.push(buf.toString('utf8').replace(requireRegExp, replacer));
        next();
    });

    function replacer(match, quote, require) {
        var replacement = 'require(\'';
        try {
            resolve.sync(require);
        } catch (exc) {
            try {
                // Try to resolve the require statement starting from the root folder
                resolve.sync(require, {paths: ['.']});
                replacement += relativeToRoot + path.sep;
            } catch (exc2) {
            }
        }
        replacement += require + '\')';
        return replacement;
    }
};

function _(module) {
    console.log(module.filename);
    (module.paths && module.paths.push('.'));
}
module.exports._ = _;
@@ -167,129 +167,8 @@
 fy%0A%0A
-// Import dependencies%0Avar path = require('path');%0Avar through = require('through2');%0Avar resolve = require('resolve');%0A%0A
 // T
@@ -204,16 +204,16 @@
 ression%0A
+
 var requ
@@ -265,17 +265,16 @@
 )%5Cs*/g;%0A
-%0A
 // The t
@@ -322,24 +322,199 @@
 on (file) %7B%0A
+    // Import dependencies%0A    var path = require('path');%0A    var through = require('through2');%0A    var resolve = require('resolve');%0A    // Retrieve the file relative path%0A
     var file
@@ -599,17 +599,47 @@
 , '.');%0A
+    // Transform %60require(..)%60
 %0A
-
     retu
@@ -775,17 +775,46 @@
     %7D);%0A
+    // %60require(..)%60 replacer
 %0A
-
     func
@@ -891,11 +891,17 @@
 ire(
-%5C''
+' + quote
 ;%0A  
@@ -1278,13 +1278,55 @@
 e + 
-'%5C')'
+quote + ')';%0A//        console.log(replacement)
 ;%0A  
@@ -1360,17 +1360,52 @@
    %7D%0A%7D;%0A
+// Modify the module internal paths
 %0A
-
 function
@@ -1499,16 +1499,16 @@
 .'));%0A%7D%0A
-
 module.e
@@ -1520,8 +1520,9 @@
 s._ = _;
+%0A

Move import statements into the transform function