fastify / fastify/fastify-cli

Watcher is not working on builders

Open
#717 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
733
Forks
177
Avg merge
1d 20h
Merged PRs (30d)
3

Description

## Prerequisites

- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the bug has not already been reported

## Description

Builders are a common pattern used by developers on different use-cases: https://refactoring.guru/design-patterns/builder
The watcher's default ignore pattern is containing `build` which cause the watcher to ignore all the paths with `build` in them. In my case the problem went even further since my app name is `xy-builder` and during troubleshooting I've found out that the `watcher.getWatched()` will return with an empty object every time and the hot reload won't work at all.

## Steps to Reproduce

### Init
```bash
#!/bin/bash
mkdir test
cd test
npm init
npm i fastify-cli
npx fastify-cli generate any-builder
cd any-builder
npm i
```
### Add logging to debug
1. Under `node_modules/fastify-cli/lib/watch` open the `index.js` file
2. Add `console.log(watcher.getWatched())` to ln 83 (or under `watcher.on('ready', function () {`
3. Save the file

### Reproduce error
1. Run `npm run dev`
2. See that the `console.log()` output will be `{}`

### Screenshots:
1. The buggy behaviour
image
2. Temporary removed the build from the default ignoreWatch by hardcoding the defaults into `start.js` to showcase the expected results
image

## Expected Behavior

I think the expected behaviour here should be a match for build exactly. I'm a newbie to Fastify tho so I'm not sure where `build` folder will be important since as far as I see so far the ts build's default destination is `dist/` as well. If we are not using build folders on a purpose I think maybe we could remove it from the default ignores at all but please let me know about your thoughts on this topic.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.