serverless-heaven / serverless-webpack

Serverless plugin to bundle your lambdas with Webpack
MIT License
1.72k stars 417 forks source link

WebpackOptionsValidationError: Invalid configuration object. configuration.entry should be an non-empty object #592

Closed ggmartins closed 4 years ago

ggmartins commented 4 years ago

For bug reports:

webpack throwing an error running sls deploy or sls offline

  Webpack Options Validation Error -----------------------

  WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
   - configuration.entry should be an non-empty object.

(full stack trace below)

no errors

plugins:

...


package.json

{ "name": "iotpro", "version": "0.0.1", "description": "IoT Device Managing and Profiling", "main": "handler.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Guilherme Martins", "license": "ISC", "dependencies": { "axios": "^0.19.2", "http-aws-es": "^6.0.0", "jsonwebtoken": "^8.5.1", "middy": "^0.36.0", "source-map-support": "^0.5.19", "uuid": "^8.1.0" }, "devDependencies": { "@types/jest": "^26.0.0", "@types/node": "^14.0.13", "aws-sdk": "^2.696.0", "aws-xray-sdk": "^3.1.0", "bcryptjs": "^2.4.3", "elasticsearch": "^16.7.1", "serverless": "^1.72.0", "serverless-aws-documentation": "^1.1.0", "serverless-dynamodb-local": "^0.2.39", "serverless-iam-roles-per-function": "^2.0.2", "serverless-offline": "^6.4.0", "serverless-reqvalidator-plugin": "^1.0.3", "serverless-s3-local": "^0.6.2", "serverless-webpack": "^5.3.2", "ts-loader": "^7.0.5", "typescript": "^3.9.5", "webpack": "^4.43.0" } }

webpack.config.js (auto-generated)

const path = require('path'); const slsw = require('serverless-webpack');

module.exports = { mode: slsw.lib.webpack.isLocal ? 'development' : 'production', entry: slsw.lib.entries, devtool: 'source-map', resolve: { extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'], }, output: { libraryTarget: 'commonjs', path: path.join(__dirname, '.webpack'), filename: '[name].js', }, target: 'node', module: { rules: [ // all files with a .ts or .tsx extension will be handled by ts-loader { test: /.tsx?$/, loader: 'ts-loader' }, ], }, };


* What stacktrace or error message from your provider did you see?

sls deploy Serverless: Bundling with Webpack...

Webpack Options Validation Error -----------------------

WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.

For feature proposals:

Similar or dependent issue(s):

Additional Data

xuanswe commented 4 years ago

To find the actual problem, I think you should post your full serverless.yml.

ggmartins commented 4 years ago

thanks, that's ok, I fixed this by generating a new configuration from template:

sls create --template aws-nodejs-typescript --path iotpro