Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitca69794

Browse files
committed
feat: upgradechokidar to v4,close#891
1 parentad61253 commitca69794

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

‎package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
}
9999
},
100100
"dependencies": {
101-
"chokidar":"^3.6.0",
101+
"chokidar":"^4.0.3",
102102
"debug":"^4.4.3",
103103
"local-pkg":"^1.1.2",
104104
"magic-string":"^0.30.19",
@@ -115,7 +115,6 @@
115115
"@nuxt/kit":"^4.1.3",
116116
"@nuxt/schema":"^4.1.3",
117117
"@types/debug":"^4.1.12",
118-
"@types/minimatch":"^6.0.0",
119118
"@types/node":"^24.8.1",
120119
"bumpp":"^10.3.1",
121120
"compare-versions":"^6.1.1",

‎pnpm-lock.yaml‎

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎src/core/context.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
importtype{FSWatcher}from'chokidar'
12
importtypefsfrom'node:fs'
23
importtype{UpdatePayload,ViteDevServer}from'vite'
34
importtype{ComponentInfo,Options,ResolvedOptions,Transformer}from'../types'
@@ -84,7 +85,7 @@ export class Context {
8485
this.setupWatcher(server.watcher)
8586
}
8687

87-
setupWatcher(watcher:fs.FSWatcher){
88+
setupWatcher(watcher:FSWatcher|fs.FSWatcher){
8889
const{ globs}=this.options
8990
this._removeUnused=this.options.syncMode==='overwrite'
9091
watcher
@@ -110,7 +111,7 @@ export class Context {
110111
/**
111112
* start watcher for webpack
112113
*/
113-
setupWatcherWebpack(watcher:fs.FSWatcher,emitUpdate:(path:string,type:'unlink'|'add')=>void){
114+
setupWatcherWebpack(watcher:FSWatcher,emitUpdate:(path:string,type:'unlink'|'add')=>void){
114115
const{ globs}=this.options
115116
this._removeUnused=this.options.syncMode==='overwrite'
116117
watcher

‎src/core/unplugin.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Options, PublicPluginAPI } from '../types'
44
import{existsSync}from'node:fs'
55
importprocessfrom'node:process'
66
importchokidarfrom'chokidar'
7+
import{glob}from'tinyglobby'
78
import{createUnplugin}from'unplugin'
89
import{createFilter}from'unplugin-utils'
910
import{Context}from'./context'
@@ -57,7 +58,7 @@ export default createUnplugin<Options>((options = {}) => {
5758
},
5859

5960
vite:{
60-
configResolved(config:ResolvedConfig){
61+
asyncconfigResolved(config:ResolvedConfig){
6162
ctx.setRoot(config.root)
6263
ctx.sourcemap=true
6364

@@ -76,7 +77,7 @@ export default createUnplugin<Options>((options = {}) => {
7677
}
7778

7879
if(config.build.watch&&config.command==='build')
79-
ctx.setupWatcher(chokidar.watch(ctx.options.globs))
80+
ctx.setupWatcher(chokidar.watch(awaitglob(ctx.options.globs)))
8081
},
8182
configureServer(server:ViteDevServer){
8283
ctx.setupViteServer(server)
@@ -86,17 +87,20 @@ export default createUnplugin<Options>((options = {}) => {
8687
webpack(compiler){
8788
letwatcher:Watching
8889
letfileDepQueue:{path:string,type:'unlink'|'add'}[]=[]
89-
compiler.hooks.watchRun.tap(PLUGIN_NAME,()=>{
90+
compiler.hooks.watchRun.tapAsync(PLUGIN_NAME,async()=>{
9091
// ensure watcher is ready(supported since webpack@5.0.0-rc.1)
9192
if(!watcher&&compiler.watching){
9293
watcher=compiler.watching
93-
ctx.setupWatcherWebpack(chokidar.watch(ctx.options.globs),(path:string,type:'unlink'|'add')=>{
94-
fileDepQueue.push({ path, type})
95-
// process.nextTick is for aggregated file change event
96-
process.nextTick(()=>{
97-
watcher.invalidate()
98-
})
99-
})
94+
ctx.setupWatcherWebpack(
95+
chokidar.watch(awaitglob(ctx.options.globs)),
96+
(path:string,type:'unlink'|'add')=>{
97+
fileDepQueue.push({ path, type})
98+
// process.nextTick is for aggregated file change event
99+
process.nextTick(()=>{
100+
watcher.invalidate()
101+
})
102+
},
103+
)
100104
}
101105
})
102106
compiler.hooks.compilation.tap(PLUGIN_NAME,(compilation)=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp