Q:

A module in aws cognito is missing: errorMessage": "Cannot find module './lib/browser_loader

I am trying to use cognito for my project but when I follow all the necessary set up explained I am not able to run it and in my lamda test console I get the following error:
{
  "errorMessage": "Cannot find module './lib/browser_loader'",
  "errorType": "Error",
  "stackTrace": [
  "Function.Module._load (module.js:417:25)",
  "Module.require (module.js:497:17)",
   "require (internal/module.js:20:19)",
   "Object.<anonymous> (/var/task/index.js:3651:1)",
    "__webpack_require__ (/var/task/index.js:20:30)",
   "webpackUniversalModuleDefinition (/var/task/index.js:149:28)",
   "Object.<anonymous> (/var/task/index.js:156:3)",
   "__webpack_require__ (/var/task/index.js:20:30)",
   "Object.<anonymous> (/var/task/index.js:75:18)"
  ]
 }

I follow the instruction mentioned in the following link:https://github.com/aws/amazon-cognito-identity-js
So I use webpack and json loader  to first transform the code. here is my webpack code:
{
  "name": "bnitjouathprovider",
  "version": "0.0.1",
  "description": "provide the server for password management using cognito",
  "main": "index.js",
  "scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
   "build": "webpack"
  },
  "author": "Hamed Minaee",
  "license": "ISC",
  "devDependencies": {
   "amazon-cognito-identity-js": "^1.18.0",
   "aws-sdk": "git://github.com/chrisradek/aws-sdk-js.git#webpack",
   "babel-core": "^6.24.1",
   "babel-loader": "^7.0.0",
   "babel-preset-es2015": "^6.24.1",
   "babel-preset-stage-0": "^6.24.1",
   "brfs": "^1.4.3",
   "json-loader": "^0.5.4",
   "transform-loader": "^0.2.4",
   "webpack": "^3.0.0-rc.1"
  },
 "dependencies": {
    "amazon-cognito-identity-js": "^1.18.0"
 },
 "babel": {
   "presets": [
    "es2015",
     "stage-0"
   ]
 }
}

Here is my webpack.config:
var path = require("path");
var DIST_DIR = path.resolve(__dirname, "dist");
module.exports = {
// Example setup for your project:
// The entry module that requires or imports the rest of your project.
// Must start with `./`!
entry: './',
// Place output files in `./dist/my-app.js`
output: {
    path: DIST_DIR,
    filename: 'index.js'
},
module: {
    noParse: [
        /aws\-sdk/,
    ],
    loaders: [
        {
            test: /\.json$/,
            loader: 'json'
        }
    ]
}
 };

So now I assume my code should be ready to transform. here is my code:
var AWSCognito = require('amazon-cognito-identity-js/dist/amazon-cognito-
 identity'); 

 exports.handler = function (event, context, callback) {
     registerUset();
     callback(null, "some success message");

 }

 var registerUset = function () {

 }

As you see it is just a simple java script code with nothing in it. Now when I do : npm run build I see the compiled js file and I do not get any error.
However when I zip the js and node module folder and upload and test it in lambda console I get the following error:
"errorMessage": "Cannot find module './lib/browser_loader'"

The full stack is posted at the beginning of the post. To me it does not make sense. Is it an aws bug or am I missing sth?

A:

I found the solution to my problem in case if anyone faces the same issue:
Thanks to: 
http://www.rricard.me/es6/aws/lambda/nodejs/2015/11/29/es6-on-aws-lambda.html
So basically I need to use both babel and json as loaders so the key part for solving the solution was :
module: {
 loaders: [
   {
     test: /\.js$/,
     exclude: /node_modules/,
     loader: 'babel',
     query: {
     presets: ['es2015'],
       plugins: ['syntax-flow', 'transform-flow-strip-types']
      }
    },
     {
      test: /\.json$/,
      loader: 'json'
     }
   ]
   }

