serverless-webpack: Missing entries in slsw.lib when serverless functions are defined in a separate file
This is a Bug Report
Description
For bug reports:
- What went wrong?
Webpack fails to identify entry point when serverless functions are extracted out into a separate yml file. However, it works when serverless.yml has the functions defined in the same file.
- What did you expect should have happened?
Should have identified the correct entry points in slsw.lib.entries
- What was the config you used?
❗️ This configuration fails
serverless.yml
functions:
- ${file(src/functions/index.yml)}
functions/index.yml
index:
handler: src/handler.handle
events:
- http
This configuration works fine
serverless.yml
functions:
misc:
handler: src/handler.handle
events:
- http
- 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.
Additional Data
- Serverless-Webpack Version you’re using: 5.1.0
- Webpack version you’re using: 4.2.0
- Serverless Framework Version you’re using: 1.26.1
- Operating System: linux
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 8
- Comments: 20 (6 by maintainers)
I’m experiencing the same issue since I split my serverless file.
I’m experiencing this same issue. Any solution yet?
@hectorgrecco sorry this was a long time ago. IIRC what I did was to regenerate tsx code from the template and migrate the old files to the latest version.
@hassankhan I just hit this and my setup is as you specified in https://github.com/serverless-heaven/serverless-webpack/issues/372#issuecomment-487191427. Will try and find the time to make a min repo for the issue but pretty confident this is still a bug…
@immexerxez @HyperBrain I think we are missing the point here and not focusing on the reported issue. The problem is that when I place the function declarations in the serverless.yml file, everything works as expected, however, when I extract the function declarations to a separate file and try to include that file in the yaml config, it blows up. NOTE: Serverless does support this pattern
❗️ This configuration fails
serverless.yml
functions/index.yml
This configuration works fine
serverless.yml
So this issue for me was I was just exporting my functions and the regex would fail trying to find the “.” I haven’t really been following the development of serverless over the past few months so maybe this is the accepted/expected way of doing things?