Skip to content

Commit 21b8572

Browse files
committed
fix(cli): correct watch ignore logic
1 parent 690dec0 commit 21b8572

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

packages/cli/src/app.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ await yargs(hideBin(process.argv))
116116
const closeHandlers: (() => Promise<void>)[] = [];
117117
const resolvedDir = path.resolve(args.dir);
118118

119-
await bundleSource(resolvedDir, logger);
120-
121119
const handleClose = async (): Promise<void> => {
122120
await Promise.all(
123121
closeHandlers.map(async (close) => withTimeout(close(), 400)),

packages/cli/src/commands/watch.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ export const makeWatchEvents = (
5656
error: (error: Error) => throwError(error),
5757
});
5858

59-
export const filterOnlyJsFiles: MatchFunction = (file, stats) =>
60-
(stats?.isFile() ?? false) && file.endsWith('.js');
59+
export const notAJsFile: MatchFunction = (file, stats) =>
60+
(stats?.isFile() ?? false) &&
61+
(file.includes('node_modules') || !file.endsWith('.js'));
6162

6263
/**
6364
* Start a watcher that bundles `.js` files in the target dir.
@@ -77,14 +78,8 @@ export function watchDir(dir: string, logger: Logger): WatchDirReturn {
7778
const { reject: throwError, promise: errorPromise } = makePromiseKit<never>();
7879

7980
let watcher = watch(resolvedDir, {
80-
ignoreInitial: true,
81-
ignored: [
82-
'**/node_modules/**',
83-
'**/*.test.js',
84-
'**/*.test.ts',
85-
'**/*.bundle',
86-
filterOnlyJsFiles,
87-
],
81+
ignoreInitial: false,
82+
ignored: notAJsFile,
8883
});
8984

9085
const events = makeWatchEvents(watcher, readyResolve, throwError, logger);

0 commit comments

Comments
 (0)