/* jslint evil: true */

const rawPrefix = /^raw!/;
const root = new Function('return this')();

export default (nativeRequire) => {
  // If in the browser, just return webpack’s `require`.
  if (root.window === root) return nativeRequire;

  // Else wrap `require` with the following function:
  else {
    const {readFileSync} = nativeRequire('fs');

    return (moduleId) => (rawPrefix.test(moduleId) ?

      // If the `moduleId` starts with "raw!", return contents of the
      // succeeding file path.
      readFileSync(
        moduleId
          .replace(rawPrefix, ''),
        {encoding: 'utf8'}
      ) :

      // Else just return the result of the native `require`.
      nativeRequire(moduleId)
    );
  }
};

@@ -123,14 +123,55 @@
 uire
-) =%3E %7B
+, settings) =%3E %7B%0A  const %7Bdirname%7D = settings;%0A
 %0A  /
@@ -385,16 +385,61 @@
 e('fs');
+%0A    const %7Bresolve%7D = nativeRequire('path');
 %0A%0A    re
@@ -619,27 +619,33 @@
     
-moduleId%0A          
+resolve(dirname, moduleId
 .rep
@@ -663,16 +663,17 @@
 fix, '')
+)
 ,%0A      

Add setting `dirname`