serverless / serverless/serverless

Improve `serverless dev` Performance by Allowing Custom `ignore` List

Open
#13,027 0 comments 0 reactions 0 assignees View on GitHub

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 ignore list via serverless.yml, reducing unnecessary file watching.
  • Provide a configuration option like dev.ignore, similar to package.exclude.
  • Ensure node_modules and 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
  1. Modify lib/plugins/aws/dev/index.js to:

    • Introduce a new dev.ignore configuration.
    • Merge user-defined ignore values with the existing default ignored files.
    • Ensure serverless dev does not watch files in dev.ignore.
  2. Similar to how package.exclude works, the dev.ignore values 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 ignore list 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.