serverless-webpack
serverless-webpack copied to clipboard
Missing entry point(s) when using serverless-google-cloudfunctions
Bug Report
Description
Missing entry point(s) when using serverless-google-cloudfunctions
For bug reports:
-
What went wrong? The entry point(s) of the compilation was an empty object
-
What did you expect should have happened? The entry point(s) of the compilation should contain the entries
-
What was the config you used? serverless.yml
service: sls-test
provider:
name: google
runtime: nodejs
project: test-project
credentials: ~/.gcloud/key.json
plugins:
- serverless-webpack
- serverless-google-cloudfunctions
custom:
webpack:
webpackConfig: ./webpack.config.js
includeModules: true
package:
exclude:
- node_modules/**
- .gitignore
- .git/**
functions:
first:
handler: http
events:
- http: path
webpack.config.js
const slsw = require('serverless-webpack');
const webpackNodeExternals = require('webpack-node-externals');
module.exports = {
entry: slsw.lib.entries,
target: 'node',
devtool: 'source-map',
externals: [webpackNodeExternals()],
mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
optimization: {
minimize: false
},
performance: {
hints: false
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: __dirname,
exclude: /node_modules/
}
]
}
};
- What stacktrace or error message from your provider did you see?
Serverless: Bundling with Webpack...
Webpack Options Validation Error -----------------------
Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.entry should be one of these:
object { <key>: non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function
-> The entry point(s) of the compilation.
Details:
* configuration.entry should not be empty.
-> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.
* configuration.entry should be a string.
-> An entry point without name. The string is resolved to a module which is loaded upon startup.
* configuration.entry should be an array:
[non-empty string]
* configuration.entry should be an instance of function
-> A Function returning an entry object, an entry string, an entry array or a promise to these things.
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
For feature proposals:
Similar or dependent issue(s):
Additional Data
OS: linux
Node Version: 9.3.0
Serverless Version: 1.26.1
Hi @sohailalam2 . Can you post your serverless.yml. I think it has something to do with your handler definitions of the functions that are used to create the entry points in the plugin.
Hey @HyperBrain ... its already added with the issue... please check the What was the config you used? section. Thanks Also, just FYI, I tried using the serverless generator serverless-google-cloudfunctions without the serverless-webpack and it does work.. the function was deployed successfully.
@sohailalam2 Indeed - I missed that 😄
However maybe we should ask someone who uses Google (I only use AWS right now) to get a fast solution for the problem. Imo it should be some configuration issue because others are using it successfully.
@gastonmorixe Can you help out here? I saw in #309 that you also use Google as provider.
@sohailalam2 Just comparing his sls.yml and yours, I see that he uses a switched plugin order. Can you also use tha same one, because within serverless the order is important?
@HyperBrain Thanks for the comment... I did tried changing the order and ended up with the same issue.
@pmuens Do you have any advice when using the Google provider plugin together with serverless-webpack and can help out here?
I changed entry: slsw.lib.entries to just index.js (where my function is)
And this error goes away.
it seems like the root cause is slsw.lib.entries is not finding the correct file in this case.
Anyway, works fine after you just point entry to the right thing.
BTW I was getting this error because I'm a noob and I didn't read the documentation. For anyone else running into this, just running webpack throws this error, but running serverless webpack --out dist works and gives webpack the proper entries value.
@joshughes this is ok for a single entry point, however, for complex projects, we can easily have multiple entry points and then it would be a pain to maintain all of those manually. slsw.lib.entries must return and wire up the entries as expected. This happens without any issue with the AWS provider.
@HyperBrain any update on this?
@sohailalam2 This seems to originate from different handler specifications when using AWS and Google. As I do not use Google at work nor for my private projects, can you post a sample of the function definitions or a sample repo (a bit more complex) where we can try to debug? In the original serverless.yml of the issue, it also seems that there is no "exported function" defintion in the handler defintion (http vs. http.handle). It might be, that this is the root of the issue.
If Google functions use a different semantics for the handler declarations, the plugin should interpret them differently than with AWS. That should solve the problem.
I'm also having a lot of trouble getting it to work with Google Cloud Functions (https://github.com/serverless/serverless-google-cloudfunctions)... it does not seem to support package.individually: true. Did you guys end up with a solution? Thanks!
Just get sure within your serverless.yml your- ${file(functions/function.yml)} path is ok