Repository navigation
Closed
Description
This is a Bug Report
I'm trying to exclude node_modules from the final zip package but observed unexpected includes.
What went wrong?
Some of the files in node_modules are getting into the zip because of the implicit include of 'functions'.
List of the packaged files
node_modules/aws-sdk/node_modules/jmespath/test/compliance/functions.json
node_modules/aws-sdk/node_modules/xmlbuilder/node_modules/lodash/internal/basefunctions.js
node_modules/aws-sdk/node_modules/xmlbuilder/node_modules/lodash/object/functions.js
node_modules/serverless/docs/01-guide/04-invoking-functions.md
node_modules/serverless/lib/plugins/aws/deploy/compile/functions/readme.md
node_modules/serverless/lib/plugins/aws/deploy/compile/functions/iam-policy-lambda-execution-template.json
node_modules/serverless/lib/plugins/aws/deploy/compile/functions/iam-role-lambda-execution-template.json
node_modules/serverless/lib/plugins/aws/deploy/compile/functions/index.js
node_modules/serverless/lib/plugins/aws/deploy/compile/functions/tests/index.js
node_modules/serverless/node_modules/jmespath/test/compliance/functions.json
node_modules/serverless/node_modules/lodash/_basefunctions.js
node_modules/serverless/node_modules/lodash/fp/functions.js
node_modules/serverless/node_modules/lodash/fp/functionsin.js
node_modules/serverless/node_modules/lodash/functions.js
node_modules/serverless/node_modules/lodash/functionsin.js
node_modules/serverless/node_modules/xmlbuilder/node_modules/lodash/internal/basefunctions.js
node_modules/serverless/node_modules/xmlbuilder/node_modules/lodash/object/functions.js
node_modules/serverless-offline/node_modules/babel-register/node_modules/babel-core/lib/transformation/internal-plugins/shadow-functions.js
node_modules/serverless-offline/node_modules/lodash/_basefunctions.js
node_modules/serverless-offline/node_modules/lodash/fp/functions.js
node_modules/serverless-offline/node_modules/lodash/fp/functionsin.js
node_modules/serverless-offline/node_modules/lodash/functions.js
node_modules/serverless-offline/node_modules/lodash/functionsin.j
functions/event.json
functions/handler.js
package.json
What did you expect should have happened?
The node_modules folder should completely ignored when packaging so the final package contains:
functions/event.json
functions/handler.js
package.json
What was the config you used?
package:
exclude:
- node_modulesWhat stacktrace or error message from your provider did you see?
none
Additional Data
- _Serverless Framework Version you're using_: 1.0.0-rc.1
- _Operating System_: Ubuntu 16.04.1
- _Stack Trace_: none
- _Provider Error messages_: none
Proposal 1: Quick fix
/lib/plugins/package/lib/zipService.js
29c29
< exclude.some(value => relativeFilePath.toLowerCase().indexOf(value.toLowerCase()) > -1);
---
> exclude.some(value => relativeFilePath.toLowerCase().indexOf(value.toLowerCase()) === 0);
32c32
< include.some(value => relativeFilePath.toLowerCase().indexOf(value.toLowerCase()) === -1);
---
> include.some(value => relativeFilePath.toLowerCase().indexOf(value.toLowerCase()) === 0);This will require specifying relative paths as suggested on the doc page but will prevent excluding files grobally eg. event.json
Proposal 2: Implicit and explicit paths:
package:
exclude:
- /node_modules
- event.jsonAdditional check if paths starts with a backslash would trigger one of the checks in Proposal 1
Proposal 3: The ultimate solution
Using glob patterns
package:
exclude:
- /node_modules
- event.json
- */*.jsonReacted by Maikel Zuniga and Toby Hede
Metadata
Metadata
Assignees
Labels
No labels
Activity
rowanu commentedon Sep 8, 2016
Ran in to this problem today as well. Is it just me or do the packaging docs suggest that
includesshould behave like a whitelist if used on their own?👍 for Proposal 3, happy to help if needed.
pmuens commentedon Nov 17, 2016
Thanks for reporting! 👍
We've pushed an update recently which should resolve this bug (#2681).
includeandexcludeare now implemented throughglobs. This means thatnode_modules/**will consider thenode_modulesdirectory.Closing this one for now. Let us know if this is still an issue!