Skip to content

Commit 9c58562

Browse files
committed
chore: update doc about reload dependencies
1 parent ddeec3c commit 9c58562

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

README.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,45 @@ We have some examples in the examples folder with different frameworks to help y
6969

7070
`hot.init` accepts the following options:
7171

72-
- `reload`: An array of glob patterns that specifies which files should trigger a full process reload.
73-
- `ignore`: An array of glob patterns that specifies which files should not be considered by Hot Hook. By default, ['**/node_modules/**'].
74-
- `projectRoot`: The path of the project root folder. Glob patterns are resolved relative to this path.
72+
### `reload`
73+
74+
An array of glob patterns that specifies which files should trigger a full process reload. By default, it's an empty array. Also note that if a file specified in `reload` imports another file that is not in `reload`, and this same file is modified, then the full process reload will be triggered. Let's take an example.
75+
76+
We have the following `reload` configuration:
77+
78+
```ts
79+
await hot.init({
80+
reload: ['config/**']
81+
})
82+
```
83+
84+
And we have the following files:
85+
86+
```ts
87+
// config/database.ts
88+
import { getPort } from '../app/utils.ts'
89+
90+
export const config = {
91+
port: getPort()
92+
}
93+
```
94+
95+
```ts
96+
// app/utils.ts
97+
export function getPort() {
98+
return 8080
99+
}
100+
```
101+
102+
If you modify the `app/utils.ts` file, then the `config/database.ts` file will be reloaded, even though it's not in the `reload` configuration. Because `app/utils.ts` is a dependency of `config/database.ts`.
103+
104+
### `ignore`
105+
106+
An array of glob patterns that specifies which files should not be considered by Hot Hook. That means they won't be reloaded when modified. By default, it's `['node_modules/**']`.
107+
108+
### `projectRoot`
109+
110+
The path of the project root folder. Glob patterns are resolved from this path
75111

76112
## API
77113

0 commit comments

Comments
 (0)