The problem with package.json and node_modules
See original GitHub issueThis is a Google provider related problem I encountered during usage.
Let’s pretend a user wants to use the Google Provider implementation. He would create (or download) a service. He would add a package.json
file to his service directory so that he can install all the necessary packages and of course the Serverless google
provider plugin (which is a npm package as well).
Now here are some minor problems we have to tackle:
The google-cloud
and googleapis
packages are huge (right now we include everything so that the developer has access to all Google Cloud service he needs).
Solution:
We can easily reduce this and only include the npm packages which are really needed for the deployment process (e.g. storage
and functions
, etc.). The user has to add the Google pacakges he need by hand to his service. Furthermore I’ve excluded the package.json
file and node_modules
directory in the boilerplate (see below).
The Google “handler” concept works a follows. The root directory needs a file named index.js
, function.js
or a package.json
(with an entrypoint defined). This is a problem right now as the package.json
is taken which has the Google Provider plugin as a dependency
. Completely ignoring the index.js
or function.js
of the service (if the user won’t define it in the package.json
which is not yet done by default).
Solution:
Right now I’ve excluded the package.json
and node_modules
directory in the boilerplate (see: https://github.com/serverless/boilerplate-googlecloudfunctions-nodejs/pull/2/files). This makes sure that the plugin works as expected. However package.json
files or node_modules
directories on the root level are currently not supported because of this. The user needs to add a directory, create a new package.json
and add all the dependencies he wants to use for his service there.
I hope that this is understandable. Otherwise please let me know.
As already said. This is a problem currently only the Google implementation has and is not that super critical at the time of writing (although this might change once the Google Cloud Functions service is open for everyone and larger projects are developed) but definitely needs attention soon.
/cc @serverless/team
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
@codepreneur thanks for the update and taking the initiative!
Just a quick update on this one. We’ve removed
package.json
form the excludes in all the examples, service templates and boilerplates for the Google integration (e.g. here https://github.com/serverless/serverless/pull/3644).I’ll close this issue for now since the discussion can be continued in https://github.com/serverless/serverless/issues/2895