code: function transformFile(from, to, modulesDirectory) {
    var contents = fs.readFileSync(from, 'utf8');
  
    // modules
    var modules = getModules(contents);
    for (var index in modules) {
      var module = modules[index];
      if (modulesManifest.hasOwnProperty(module)) {
        continue;
      }
      var modulePath = path_util.modulePath(module, node_modules);
      if (modulePath === null) {
        continue;
      }
      var targetPath = path_util.targetPath(modulePath, node_modules, modulesDirectory);
      modulesManifest[module] = path.relative(process.cwd(), targetPath);
      if (!fs.existsSync(targetPath)) {
        transformFile(modulePath, targetPath, modulesDirectory);
      }
      var relativePath = path_util.relativePath(to, targetPath);
      var re = eval('\/require\\\(\[\'\"\]' + module + '\[\'\"\]\\\)\/ig');
      contents = contents.replace(re, 'require(\'' + relativePath + '\')');
    }
  
    // requires
    var requires = getRequires(contents);
    for (var index in requires) {
      var require = requires[index];
      var requirePath = path_util.requirePath(from, require);
      if (requirePath === null) {
        continue;
      }
      if (requiresManifest.hasOwnProperty(requirePath)) {
        continue;
      } else {
        requiresManifest[requirePath] = true;
      }
      var targetPath = path_util.targetPath(requirePath, node_modules, modulesDirectory);
      if (!fs.existsSync(targetPath)) {
        transformFile(requirePath, targetPath, modulesDirectory);
      }
    }
  
    var dirname = path.dirname(to);
    fs.mkdirsSync(dirname);
    fs.writeFileSync(to, contents, 'utf8');
  }
docs: copy file from node_module to modulesDirectory
  
  @param from file full path
  @param to file full path
  @param modulesDirectory