serverless / serverless/serverless
Improve `serverless dev` Performance by Allowing Custom `ignore` List
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.9k
- Forks
- 5.7k
- Avg merge
- 10h 7m
- Merged PRs (30d)
- 57
Description
Is there an existing issue for this?
- I have searched existing issues, it hasn't been reported yet
Use case description
Description:
Currently, the ignore list in lib/plugins/aws/dev/index.js#L105 is hardcoded, leading to performance issues when running serverless dev. By default, too many files are watched, especially in large projects with node_modules, .git, or other directories that do not need to be tracked.
Feature Request:
- Allow users to customize the
ignorelist viaserverless.yml, reducing unnecessary file watching. - Provide a configuration option like
dev.ignore, similar topackage.exclude. - Ensure
node_modulesand other large directories can be explicitly ignored for better performance.
Use Case:
This would significantly improve performance for developers working in monorepos, large projects, or environments where serverless dev is slowed down due to excessive file watching.
Potential Solution:
Modify the ignore array to include user-defined values from serverless.yml. This could work similarly to package.exclude, allowing better control over which files are watched.
Would love to hear thoughts from the maintainers on the best way to implement this! 🚀
Proposed solution (optional)
Proposed Solution: dev.ignore (Similar to package.exclude)
To improve the performance of serverless dev, we propose adding a new configuration option in serverless.yml:
New Configuration Option
service: my-service
provider:
name: aws
custom:
dev:
ignore: # or watchIgnore
- node_modules/** # Ignore node_modules to improve performance
- .git/** # Ignore git directory
- logs/** # Ignore logs
Implementation Suggestion
-
Modify
lib/plugins/aws/dev/index.jsto:- Introduce a new
dev.ignoreconfiguration. - Merge user-defined
ignorevalues with the existing default ignored files. - Ensure
serverless devdoes not watch files indev.ignore.
- Introduce a new
-
Similar to how
package.excludeworks, thedev.ignorevalues should be processed before setting up file watchers to prevent unnecessary CPU/memory usage.
Example Code Change (Simplified)
Modify the existing ignore list in lib/plugins/aws/dev/index.js#L105 to:
const userIgnoreList = serverless.service.custom?.dev?.ignore || [];
const defaultIgnoreList = ['.serverless', '.git', 'node_modules'];
const ignore = [...new Set([...defaultIgnoreList, ...userIgnoreList])];
This ensures:
- The default
ignorelist remains intact. - Users can extend it via
serverless.yml. - Performance issues caused by excessive file watching are mitigated.
Would love feedback on this approach! 🚀
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/plugins/aws/dev/index.js at the hardcoded ignore list around line 105, then inspect how serverless.yml configuration such as package.exclude is processed. Clarify whether the option belongs under dev or custom.dev, preserve the existing defaults, and verify that configured paths are excluded before file watchers are created. Done means serverless dev accepts the documented ignore list and avoids watching those paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- devtools, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100