Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dev watcher to ignore more accurately #40412

Merged
merged 5 commits into from Sep 11, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/next/server/dev/next-dev-server.ts
Expand Up @@ -273,12 +273,10 @@ export default class DevServer extends Server {
})
}

const wp = (this.webpackWatcher = new Watchpack({
ignored: /([/\\]node_modules[/\\]|[/\\]\.next[/\\]|[/\\]\.git[/\\])/,
}))
const pages = this.pagesDir ? [this.pagesDir] : []
const app = this.appDir ? [this.appDir] : []
const directories = [...pages, ...app]

const files = this.pagesDir
? getPossibleMiddlewareFilenames(
pathJoin(this.pagesDir, '..'),
Expand All @@ -296,13 +294,25 @@ export default class DevServer extends Server {

files.push(...envFiles)

console.log('directories', directories)
ijjk marked this conversation as resolved.
Show resolved Hide resolved
console.log('files', files)

// tsconfig/jsonfig paths hot-reloading
const tsconfigPaths = [
pathJoin(this.dir, 'tsconfig.json'),
pathJoin(this.dir, 'jsconfig.json'),
]
files.push(...tsconfigPaths)

const wp = (this.webpackWatcher = new Watchpack({
ignored: (pathname: string) => {
return (
!files.some((file) => file.startsWith(pathname)) &&
!directories.some((dir) => pathname.startsWith(dir))
)
},
}))

wp.watch({ directories: [this.dir], startTime: 0 })
const fileWatchTimes = new Map()
let enabledTypeScript = this.usingTypeScript
Expand Down