Skip to content

Commit 135ff39

Browse files
committedJul 25, 2022
fix: actually trigger rebuild when watched files change
1 parent 8dbb97d commit 135ff39

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed
 

‎src/index.ts

+20-15
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export const defineConfig = (
2828
| Options
2929
| Options[]
3030
| ((
31-
/** The options derived from CLI flags */
32-
overrideOptions: Options
33-
) => MaybePromise<Options | Options[]>)
31+
/** The options derived from CLI flags */
32+
overrideOptions: Options
33+
) => MaybePromise<Options | Options[]>)
3434
) => options
3535

3636
const killProcess = ({
@@ -67,8 +67,8 @@ const normalizeOptions = async (
6767
? {}
6868
: undefined
6969
: typeof _options.dts === 'string'
70-
? { entry: _options.dts }
71-
: _options.dts,
70+
? { entry: _options.dts }
71+
: _options.dts,
7272
}
7373

7474
setSilent(options.silent)
@@ -120,9 +120,9 @@ export async function build(_options: Options) {
120120
_options.config === false
121121
? {}
122122
: await loadTsupConfig(
123-
process.cwd(),
124-
_options.config === true ? undefined : _options.config
125-
)
123+
process.cwd(),
124+
_options.config === true ? undefined : _options.config
125+
)
126126

127127
const configData =
128128
typeof config.data === 'function'
@@ -272,16 +272,17 @@ export async function build(_options: Options) {
272272
typeof options.watch === 'boolean'
273273
? '.'
274274
: Array.isArray(options.watch)
275-
? options.watch.filter(
275+
? options.watch.filter(
276276
(path): path is string => typeof path === 'string'
277277
)
278-
: options.watch
278+
: options.watch
279279

280280
logger.info(
281281
'CLI',
282-
`Watching for changes in ${Array.isArray(watchPaths)
283-
? watchPaths.map((v) => '"' + v + '"').join(' | ')
284-
: '"' + watchPaths + '"'
282+
`Watching for changes in ${
283+
Array.isArray(watchPaths)
284+
? watchPaths.map((v) => '"' + v + '"').join(' | ')
285+
: '"' + watchPaths + '"'
285286
}`
286287
)
287288
logger.info(
@@ -298,8 +299,12 @@ export async function build(_options: Options) {
298299
})
299300
watcher.on('all', (type, file) => {
300301
file = slash(file)
301-
if (!buildDependencies.has(file)) return
302-
302+
// By default we only rebuild when imported files change
303+
// If you specify custom `watch`, a string or multiple strings
304+
// We rebuild when those files change
305+
if (options.watch === true && !buildDependencies.has(file)) {
306+
return
307+
}
303308
logger.info('CLI', `Change detected: ${type} ${file}`)
304309
debouncedBuildAll()
305310
})

0 commit comments

Comments
 (0)
Please sign in to comment.